Get client tools setup for Jenkins. Integration with Jenkins will allow for automation into a CI/CD pipeline.
Jenkins build system
Any agent with OS that supports Java on Jenkins
JDK installed on the agent
setup
client for your OS
Signing tools present for the required signing (such as signtool.exe or mage.exe)
Note
You can download client tools from the DigiCert ONE® portal in the > Resources > Client tool repository.
DigiCert® KeyLocker clients can be downloaded in a package.
Sign in to DigiCert ONE.
Navigate to DigiCert® KeyLocker > Resources > Client tool repository.
Select your operating system.
Click the download icon next to DigiCert® KeyLocker clients.
To register the KSP, open a command prompt and run:
smksp_registrar.exe register
To verify that your KSP is configured properly, and that your client can properly authenticate to the DigiCert® KeyLocker service, run:
certutil.exe -csp "DigiCert Software Trust Manager KSP" -key -user
For the client tools to access the private keys in the service through the Key Storage Provider (KSP), your certificates must be synchronized to the local certificate store. Only if the certificate is synchronized, the private key remains stored securely in DigiCert® KeyLocker.
To synchronize your certificates to the local certificate store, open a command prompt and run:
smksp_cert_sync.exe
To view the certificates, open Certificate Manager for the user account used to run the certificate sync utility:
certmgr.msc
If you do not see your certificates in the Certificate Manager, verify that you have opened the correct certificate store. There is a different certificate store for each Windows user account.
Note
All certificates are synched to the user store only. The certificates are not synchronized to the machine store (yet).
Operating systems use the environment variable called PATH to determine where executable files are stored on your system. Use the PATH environment variable to store the file path to your signing tools to ensure that the CLI can reference these signing tools.
DigiCert® KeyLocker enforces multifactor authentication for security. To access keypairs, certificates, and sign code, you need to set up two types of credentials: an API token and an authentication certificate.
The API token is an authentication method used to verify you as a user and your permissions assigned in DigiCert ONE. The API token provides the first factor authentication.
Follow these steps to generate an API token:
Sign in to DigiCert ONE.
Select the profile icon (top-right).
Select Admin Profile.
Scroll down to API Tokens.
Select Create API token.
Note
The API token is only shown once, securely store the API key to use it later.
The client authentication certificate is an authentication method used to verify you as a user and your permissions assigned in DigiCert ONE. The client authentication certificate provides the second factor authentication.
Follow these steps to create a client authentication certificate:
Sign in to DigiCert ONE.
Select the profile icon (top-right).
Select Admin Profile.
Scroll down to Authentication certificates.
Select Create authentication certificate.
Set the following environment variables:
Variable | Description |
---|---|
SM_API_KEY | Provide your API token. |
SM_CLIENT_CERT_FILE | Provide your client authentication certificate. |
SM_CLIENT_CERT_PASSWORD | Provide your client certificate password. |
SM_HOST | Provide your host environment. |
Follow the instructions in the articles below to integrate with signing tools.
Note
For more information regarding which file types can be signed with these signing tools, refer to: Integrate third-party signing tools.
Environment variables setup for pipeline
The client tools need these environment variables to connect with to provide its service. They can be integrated as environment variables that are part of the pipeline as shown in the example below or they can be configured at an OS environment level.
pipeline {
environment{
SM_CLIENT_CERT_PASSWORD='**********'
SM_CLIENT_CERT_FILE='<Path to client Auth Cert File>'
SM_HOST='https://clientauth.one.digicert.com'
SM_API_KEY='<Api Token>'
}
}
You can sign with Jarsigner, Mage, NuGet, or SignTool.
To sign with SignTool:
stage('sign') {
steps {
bat 'signtool.exe sign /csp "DigiCert Signing Manager KSP" /kc "KeypairAlias" /f certificate.crt /tr http://timestamp.digicert.com UNSIGNED.EXE'
}
The input parameters are the alias of the keypair used for signing, the name/alias of the certificate that needs to be used for signing, and the path to the file that needs to be signed.
To sign with Mage:
stage('sign') {
steps {
bat 'mage -sign deploy.application -CertFile certificate.crt -KeyContainer KeypairAlias -CryptoProvider “DigiCert Signing Manager KSP” '
}
The input parameters are the path to the file that needs to be signed, the name/alias of the certificate that needs to be used for signing, and the alias of the keypair used for signing.
To sign with NuGet:
stage('sign') {
steps {
bat 'nuget sign HelloWorld.1.3.0.17\* -Timestamper http://timestamp.digicert.com -outputdirectory ..\am-HelloWorld.1.3.0.17 -CertificateFingerprint fe509cdc76517a18a37d927e770216b35683d656 -Verbosity detailed -Overwrite'
}
The input parameters are the the path to the file that needs to be signed, the path of the output signed file, and the fingerprint of the certificate that needs to be used for signing.
To sign with Jarsigner:
stage('sign') {
steps {
bat 'jarsigner -keystore NONE -storetype Windows-My -signedjar <signed_file>.jar -sigalg SHA256withRSA -digestalg SHA256 <jarfile> <alias>'
}
The input parameters are the path where the signed jar needs to be output, the path to the jar that needs to be signed, and the name/alias of the certificate that needs to be used for signing.
You can verify a signature with Jarsigner, Mage, NuGet, or SignTool.
To verify a signature with Jarsigner:
stage('verify') {
steps {
bat 'jarsigner -verify <Path to Signed Jar>'
}
To verify a signature with Mage:
stage('verify') {
steps {
bat 'mage.exe -verify deploy.application'
}
To verify a signature with NuGet:
stage('verify') {
steps {
bat 'nuget verify -All am-HelloWorld.1.3.0.17\*'
}
To verify a signature with SignTool:
stage('verify') {
steps {
bat 'signtool.exe sign verify /v /pa UNSIGNED.EXE'
}