CircleCI の統合 –KSP
前提条件
A GitHub repository
お使いのOSに対応する DigiCert® Software Trust Manager クライアント
DigiCert® Software Trust Manager KSP (クライアントツール)
Client tools
DigiCert® Software Trust Manager clients can be downloaded in a package.
Download Client tools
Sign in to DigiCert ONE.
Navigate to DigiCert® Software Trust Manager > Resources > Client tool repository.
Select your operating system.
Click the download icon next to DigiCert® Software Trust Manager clients.
Register the KSP
To register the KSP, open a command prompt and run:
smksp_registrar.exe register
Verify the KSP
To verify that your KSP is configured properly, and that your client can properly authenticate to the DigiCert® Software Trust Manager service, run:
certutil.exe -csp "DigiCert Software Trust Manager KSP" -key -user
Synchronize certificates
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® Software Trust Manager.
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.
注記
All certificates are synched to the user store only. The certificates are not synchronized to the machine store (yet).
Set PATH environment variables
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.
User authentication
Software Trust Manager 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.
Create an API token
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.
注記
The API token is only shown once, securely store the API key to use it later.
Create an authentication certificate
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.
注記
The client authentication certificate password shown after creating an client authentication certificate cannot be accessed again, download the certificate and securely store the password to use it later.
DigiCert® Software Trust Managerのセットアップ
システム変数として設定することで、環境変数が永続的に残るようにしてください。
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. |
クライアントツールの設定
クライアントコントロールのセットアップ
OSに基づき、DigiCert® Software Trust Manager > リソース > クライアントツールから、任意のパッケージで DigiCert® Software Trust Manager クライアントをダウンロードします。CircleCI からクライアントコントロールを起動するために、以下の curl コマンドで smtools-Windows-x64.msIをダウンロードしてインストールします。
steps: - checkout - run: name: "Client-Tool-Setup" command: | cd C:\ curl.exe -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download -H "x-api-key:$env:SM_API_KEY" -o smtools-windows-x64.msi
msiexec.exe /i smtools-windows-x64.msi /quiet /qn | Wait-Process
steps: - checkout - run: name: "Client-Tool-Setup" command: | cd C:\ curl.exe -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/Keylockertools-windows-x64.msi/download -H "x-api-key:$env:SM_API_KEY" -o Keylockertools-windows-x64.msi msiexec.exe /i Keylockertools-windows-x64.msi /quiet /qn | Wait-Process
注記
"curl "コマンドは smtools-Windows-x64.msi のインストーラーを、"msiexec"は smtools-Windows-x64.msi のサイレントインストールに使用されるものである。
KSPを確認する
KSPが登録されていることを確認するには、以下を実行します。
steps:
- checkout
- run:
name: "Verify-KSP"
command: |
& $env:SSM\smksp_registrar.exe list
environment:
SSM: 'C:\Program Files\DigiCert\DigiCert One Signing Manager Tools'
Integration with CircleCI
Find SignTool and Mage
Command to find SignTool:
steps: - checkout - run: name: "Find Signtool" command: | Get-ChildItem -Path 'C:\Program Files (x86)\Windows Kits\10\App Certification Kit' -Filter signtool.exe -Recurse
Command to find Mage:
steps: - checkout - run: name: "Find Mage" command: | Get-ChildItem -Path 'C:\Program Files (x86)\Microsoft SDKs\Windows' -Filter mage.exe -Recurse
CircleCI との統合
テスト用鍵ペアと証明書を作成する
証明書付きの RSA テスト鍵ペアを生成する CircleCI のステップの例:
steps:
- checkout
- run:
name: "Create-Test-Keypair"
command: |
& $env:SSM\smctl.exe keypair generate rsa <Keypair Name> --cert-alias=<Certificate Name> --cert-profile-id=<Certificate Profile ID> --generate-cert=true --key-type=TEST
environment:
SSM: 'C:\Program Files\DigiCert\DigiCert One Signing Manager Tools'
鍵ペア名と証明書名は、一意の入力でなければなりません。つまりポータル上に既に存在することはできません。証明書プロファイルIDは DigiCert ONEポータルの DigiCert® Software Trust Manager > 証明書 > 証明書管理 > 証明書プロファイルで取得できます。証明書の生成に使用するプロファイルを選択します(カテゴリは「テスト」でなければなりません)。図のようなプロファイルIDが表示されます。
To retrieve the certificate profile ID:
Sign in to DigiCert ONE.
Navigate to:DigiCert® Software Trust Manager > Certificates > Certificate profiles.
Select a certificate profile that you want to use to generate the certificate.
注記
Certificate profile category should be Test.
Identify the Certificate profile ID field.
証明書付きの鍵ペアを作成する
証明書付きの RSA プロダクション鍵ペアを生成する CircleCI パイプラインのステップの例:
steps:
- checkout
- run:
name: "Create-Production-Keypair"
command: |
& $env:SSM\smctl.exe keypair generate rsa <Keypair Name> --cert-alias=<Certificate Name> --cert-profile-id=<Certificate Profile ID> --generate-cert=true --key-type=PRODUCTION
environment:
SSM: 'C:\Program Files\DigiCert\DigiCert One Signing Manager Tools'
パラメータは前の場合と同じですが、プロファイルカテゴリが「プロダクション」である証明書プロファイルを選択していることを確認してください。
既存の鍵ペアから証明書を作成する
既存の鍵ペアの証明書を生成する CircleCI パイプラインステップの例:
steps:
- checkout
- run:
name: "Create-Certificate"
command: |
& $env:SSM\smctl.exe keypair generate-cert <Keypair ID> --cert-alias=<Certificate Name> --cert-profile-id=<Certificate Profile ID>
environment:
SSM: 'C:\Program Files\DigiCert\DigiCert One Signing Manager Tools'
このステップで必要な入力は、鍵ペアID、証明書名(一意でなければなりません)、および証明書プロファイルIDです。鍵ペアIDを取得するには、次の2つの方法があります。
You can retrieve the keypair ID in two ways:
すべての環境変数が設定された状態で、コマンドラインから [smctl 鍵ペアはコマンド] を実行します。
DigiCert ONE > DigiCert® Software Trust Manager -> 鍵の管理を参照し、鍵ペアを選択します。
前述の使用ケースと同様に、使用する証明書プロファイルIDは正しいプロファイルカテゴリに属していなければなりません。
Sign
You can sign using Mage, NuGet, or SignTool. These commands require the certificate thumbprint.
Sign with SignTool
To sign with SignTool:
steps: - checkout - run: name: "Signtool-Signing" command: | & $env:Signtool sign /sha1 <certificate thumbprint> /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 <file to be signed> environment: Signtool: 'C:\Program Files (x86)\Windows Kits\10\App Certification Kit\signtool.exe'
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.
Sign with Mage
To sign with Mage:
steps: - checkout - run: name: "Mage-Signing" command: | & $env:Mage -sign <file_name> -CertHash <hash_or_cert_fingerprint> -a sha256RSA environment: Mage: 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\mage.exe'
The input parameters are the path to the .application file to be signed and the thumbprint of the certificate. You can find the thumbprint on the Certificate details page in DigiCert ONE.
Sign with NuGet
To sign with NuGet:
steps: - checkout - run: name: "Nuget-Signing" command: | 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. You can find the certificate thumbprint on Certificate details page in DigiCert ONE.
Verify signature
You can verify a signature using Mage, NuGet, or SignTool.
Verify signature with Mage
To verify a signature with Mage:
steps: - checkout - run: name: "Mage-Verification" command: | & $env:Mage -Verify <Path to signed .application file> environment: Mage: 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\mage.exe'
The only input required here is the path to the signed .application file.
Verify signature with NuGet
To verify a signature with NuGet:
steps: - checkout - run: name: "Nuget-Verification" command: | nuget verify -All <output folder>\*
Verify signature with SignTool
To verify a signature with SignTool:
steps: - checkout - run: name: "Signtool-Verification" command: | & $env:Signtool verify /v /pa <Path to the signed exe/DLL> environment: Signtool: 'C:\Program Files (x86)\Windows Kits\10\App Certification Kit\signtool.exe'
The only input for this step is the path to the signed .exe or .dll that needs to be verified.
CircleCI の例
CircleCI を使用するKSPの署名
version: 2.1 orbs: win: circleci/windows@4.1 jobs: SSM_Signing: executor: win/server-2022 steps: - checkout - run: name: "Certificate-Setup" command: | cd C:\ New-Item C:\CERT_FILE.p12.b64 Set-Content -Path C:\CERT_FILE.p12.b64 -Value $env:SM_CLIENT_CERT_FILE_B64 certutil -decode CERT_FILE.p12.b64 Certificate_pkcs12.p12 cat Certificate_pkcs12.p12 - run: name: "Client-Tool-Setup" command: | cd C:\ curl.exe -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download -H "x-api-key:$env:SM_API_KEY" -o smtools-windows-x64.msi msiexec.exe /i smtools-windows-x64.msi /quiet /qn | Wait-Process & 'C:\Program Files\DigiCert\DigiCert One Signing Manager Tools\smksp_cert_sync.exe' - run: name: "Signtool-Signing" command: | Get-ChildItem -Path 'C:\Program Files (x86)\Windows Kits\10\App Certification Kit' -Filter signtool.exe -Recurse Copy-Item -Path C:\Users\circleci.PACKER-624EE792\project\UNSIGNED.EXE -Destination C:\ & $env:Signtool sign /sha1 $env:SM_CODE_SIGNING_CERT_SHA1_HASH /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 C:\UNSIGNED.EXE & $env:Signtool verify /v /pa C:\UNSIGNED.EXE - run: name: "Nuget-Signing" command: | Copy-Item -Path C:\Users\circleci.PACKER-624EE792\project\UNSIGNED.nupkg -Destination C:\ nuget sign C:\UNSIGNED.nupkg -Timestamper http://timestamp.digicert.com -outputdirectory C:\Signed -CertificateFingerprint $env:SM_CODE_SIGNING_CERT_SHA1_HASH -HashAlgorithm SHA256 -Verbosity detailed -Overwrite nuget verify -All C:\Signed\* - run: name: "Mage-Signing" command: | Copy-Item -Path C:\Users\circleci.PACKER-624EE792\project\UNSIGNED1.manifest -Destination C:\ & $env:Mage -sign C:\UNSIGNED1.manifest -CertHash $env:SM_CODE_SIGNING_CERT_SHA1_HASH -a sha256RSA & $env:Mage -Verify C:\UNSIGNED1.manifest environment: SM_CLIENT_CERT_FILE: 'C:\Certificate_pkcs12.p12' 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' workflows: my-workflow: jobs: - SSM_Signing
version: 2.1
orbs:
win: circleci/windows@4.1
jobs:
SSM_Signing:
executor: win/server-2022
steps:
- checkout
- run:
name: "Certificate-Setup"
command: |
cd C:\
New-Item C:\CERT_FILE.p12.b64
Set-Content -Path C:\CERT_FILE.p12.b64 -Value $env:SM_CLIENT_CERT_FILE_B64
certutil -decode CERT_FILE.p12.b64 Certificate_pkcs12.p12
cat Certificate_pkcs12.p12
- run:
name: "Client-Tool-Setup"
command: |
cd C:\
curl.exe -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/Keylockertools-windows-x64.msi/download -H "x-api-key:$env:SM_API_KEY" -o Keylockertools-windows-x64.msi
msiexec.exe /i Keylockertools-windows-x64.msi /quiet /qn | Wait-Process
& 'C:\Program Files\DigiCert\DigiCert One Signing Manager Tools\smksp_cert_sync.exe'
- run:
name: "Signtool-Signing"
command: |
Get-ChildItem -Path 'C:\Program Files (x86)\Windows Kits\10\App Certification Kit' -Filter signtool.exe -Recurse
Copy-Item -Path C:\Users\circleci.PACKER-624EE792\project\UNSIGNED.EXE -Destination C:\
& $env:Signtool sign /sha1 $env:SM_CODE_SIGNING_CERT_SHA1_HASH /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 C:\UNSIGNED.EXE
& $env:Signtool verify /v /pa C:\UNSIGNED.EXE
- run:
name: "Nuget-Signing"
command: |
Copy-Item -Path C:\Users\circleci.PACKER-624EE792\project\UNSIGNED.nupkg -Destination C:\
nuget sign C:\UNSIGNED.nupkg -Timestamper http://timestamp.digicert.com -outputdirectory C:\Signed -CertificateFingerprint $env:SM_CODE_SIGNING_CERT_SHA1_HASH -HashAlgorithm SHA256 -Verbosity detailed -Overwrite
nuget verify -All C:\Signed\*
- run:
name: "Mage-Signing"
command: |
Copy-Item -Path C:\Users\circleci.PACKER-624EE792\project\UNSIGNED1.manifest -Destination C:\
& $env:Mage -sign C:\UNSIGNED1.manifest -CertHash $env:SM_CODE_SIGNING_CERT_SHA1_HASH -a sha256RSA
& $env:Mage -Verify C:\UNSIGNED1.manifest
environment:
SM_CLIENT_CERT_FILE: 'C:\Certificate_pkcs12.p12'
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'
workflows:
my-workflow:
jobs:
- SSM_Signing