A GitLab repository
DigiCert® KeyLocker credentials
DigiCert® KeyLocker client tools
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. |
Identify your client authentication certificate.
Encode the file to base64. For encoding run command:
base64 file_name
In GitLab > CI/CD Settings > Variables add the new variables:
Key = SM_CLIENT_CERT_FILE_B64 Value = encoded value from base64 file_name
Setup certificate file for signing:
stages: - set-SM-certificate variables: SM_API_KEY: $SM_API_KEY SM_CLIENT_CERT_PASSWORD: $SM_CLIENT_CERT_PASSWORD SM_HOST: $SM_HOST set_SM_certificate: stage: set-SM-certificate tags: - saas-windows-medium-amd64 script: - | cd C:\ New-Item C:\CERT_FILE.p12.b64 Set-Content -Path C:\CERT_FILE.p12.b64 -Value $SM_CLIENT_CERT_FILE_B64 certutil -decode CERT_FILE.p12.b64 Certificate_pkcs12.p12 variables: SM_CLIENT_CERT_FILE: 'C:\Certificate_pkcs12.p12'
The client tools need these environment variables to connect with DigiCert® KeyLocker.
They can be integrated as GitLab variables in GitLab Repository.
The values for these environment variables:
Environment variables | Description |
---|---|
SM_CLIENT_CERT_PASSWORD | The password from client authentication certificate setup. |
SM_CLIENT_CERT_FILE_B64 | The base64 encoded text of certificate downloaded from client authentication certificate setup. |
SM_HOST | The path to the DigiCert ONE portal with client authorization. NoteIn most cases, this path stays as it is unless you are connecting to a self-hosted instance of the DigiCert ONE product. |
SM_API_KEY | The API token generated during API token setup. |
SM_CODE_SIGNING_CERT_SHA1_HASH | The certificate fingerprint. |
Command to set environment variables:
stages:
- set-variables
variables:
SM_API_KEY: $SM_API_KEY
SM_CLIENT_CERT_PASSWORD: $SM_CLIENT_CERT_PASSWORD
SM_HOST: $SM_HOST
SIGNTOOL: 'C:\Program Files (x86)\Windows Kits\10\App Certification Kit\signtool.exe'
MAGE: 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\mage.exe'
SSM: 'C:\Program Files\DigiCert\DigiCert ONE Signing Manager Tools'
Note
"C:\Program Files (x86)\Windows Kits\10\App Certification Kit" is the path of signtool.exe and "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools" is the path of mage.exe
Client control setup
Download and install the Keylockertools-windows-x64.msi using curl command given below, to invoke the client control from GitLab CI/CD:
stages:
- set-SM-certificate
set_SM_certificate:
stage: set-SM-certificate
tags:
- saas-windows-medium-amd64
script:
- |
curl.exe -X GET https://ONE.digicert.com/signingmanager/api-ui/v1/releases/Keylockertools-windows-x64.msi/download -H "x-api-key: $SM_API_KEY" -o Keylockertools-windows-x64.msi
msiexec.exe /i Keylockertools-windows-x64.msi /quiet /qn | Wait-Process
Note
“curl” command is used to install the Keylockertools-windows-x64.msi installer and “msiexec” is used to silently install the Keylockertools-windows-x64.msi.
Verify the KSP
To verify that the KSP is registered, run:
stages:
- set-SM-certificate
set_SM_certificate:
stage: set-SM-certificate
tags:
- saas-windows-medium-amd64
script:
- |
& $SSM\smksp_registrar.exe list
Find Signtool and Mage
Command to find signtool:
stages:
- set-SM-certificate
set_SM_certificate:
stage: set-SM-certificate
tags:
- saas-windows-medium-amd64
script:
- |
Get-ChildItem -Path 'C:\Program Files (x86)\Windows Kits\10\App Certification Kit' -Filter signtool.exe -Recurse
Command to find Mage:
stages:
- set-SM-certificate
set_SM_certificate:
stage: set-SM-certificate
tags:
- saas-windows-medium-amd64
script:
- |
Get-ChildItem -Path 'C:\Program Files (x86)\Microsoft SDKs\Windows' -Filter mage.exe -Recurse
You can sign with Mage, NuGet, or SignTool.
To sign with SignTool:
stages:
- set-SM-certificate
set_SM_certificate:
stage: set-SM-certificate
tags:
- saas-windows-medium-amd64
script:
- |
& $SIGNTOOL sign /sha1 <certificate thumbprint> /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 <file to be signed>
The input parameters are the thumbprint of the certificate to be used for signing and the path to the .exe or .dll to be signed.
To sign with Mage:
Signing using nuget.exe:
stages:
- set-SM-certificate
set_SM_certificate:
stage: set-SM-certificate
tags:
- saas-windows-medium-amd64
script:
- |
nuget sign <package folder> -Timestamper http://timestamp.digicert.com -outputdirectory <output folder> -Certificate Fingerprint <SHA1 Thumbprint> -HashAlgorithm SHA256 -Verbosity detailed -Overwrite
The inputs to this task are the path to the package and the thumbprint of the certificate. The certificate thumbprint on can be identified on the certificate details page in DigiCert ONE portal.
You can verify a signature with Mage, NuGet, or SignTool.
To verify a signature with Mage:
stages:
- set-SM-certificate
set_SM_certificate:
stage: set-SM-certificate
tags:
- saas-windows-medium-amd64
script:
- |
& $MAGE -Verify <Path to signed .application file>
The only input required here is the path to the signed .application file.
To verify a signature with NuGet:
stages:
- set-SM-certificate
set_SM_certificate:
stage: set-SM-certificate
tags:
- saas-windows-medium-amd64
script:
- |
nuget verify -All <output folder>\*
The only input required here is the path to the signed folder.
To verify a signature with SignTool:
stages:
- set-SM-certificate
set_SM_certificate:
stage: set-SM-certificate
tags:
- saas-windows-medium-amd64
script:
- |
& $SIGNTOOL verify /v /pa <Path to the signed .exe or .dll>
The only input for this step is the path to the signed .exe or .dll that needs to be verified.
KSP Signing using GitLab CI/CD
stages:
- set-variables
- ksp-signing
variables:
SM_API_KEY: $SM_API_KEY
SM_CLIENT_CERT_PASSWORD: $SM_CLIENT_CERT_PASSWORD
SM_HOST: $SM_HOST
SIGNTOOL: 'C:\Program Files (x86)\Windows Kits\10\App Certification Kit\signtool.exe'
MAGE: 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\mage.exe'
SSM: 'C:\Program Files\DigiCert\DigiCert ONE Signing Manager Tools'
ksp_signing_job:
stage: ksp-signing
tags:
- saas-windows-medium-amd64
variables:
SM_CLIENT_CERT_FILE: 'C:\Certificate_pkcs12.p12'
script:
- |
cd C:\
New-Item C:\CERT_FILE.p12.b64
Set-Content -Path C:\CERT_FILE.p12.b64 -Value $SM_CLIENT_CERT_FILE_B64
certutil -decode CERT_FILE.p12.b64 Certificate_pkcs12.p12
curl.exe -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/Keylockertools-windows-x64.msi/download -H "x-api-key:019d9d49dd7271dd236e84fb83_c879133c1c3f524f2ef68327674135080d34018a3d6128b84e5c982c5769b088" -o Keylockertools-windows-x64.msi
msiexec.exe /i Keylockertools-windows-x64.msi /quiet /qn | Wait-Process
& $SSM\smksp_cert_sync.exe
Copy-Item -Path GitLab-Runner\builds\mypersonal23\signing\UNSIGNED.EXE -Destination C:\
Copy-Item -Path GitLab-Runner\builds\mypersonal23\signing\UNSIGNED1.manifest -Destination C:\
Copy-Item -Path GitLab-Runner\builds\mypersonal23\signing\UNSIGNED.nupkg -Destination C:\
dir 'C:\'
& $SIGNTOOL sign /sha1 $SM_CODE_SIGNING_CERT_SHA1_HASH /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 C:\UNSIGNED.EXE
& $SIGNTOOL verify /v /pa C:\UNSIGNED.EXE
& $MAGE -sign C:\UNSIGNED1.manifest -CertHash $SM_CODE_SIGNING_CERT_SHA1_HASH -a sha256RSA
& $MAGE -Verify C:\UNSIGNED1.manifest
nuget sign C:\UNSIGNED.nupkg -Timestamper http://timestamp.digicert.com -outputdirectory C:\Signed -CertificateFingerprint $SM_CODE_SIGNING_CERT_SHA1_HASH -HashAlgorithm SHA256 -Verbosity detailed -Overwrite
nuget verify -All C:\Signed\*
dir C:\