PKCS11とのAnt統合
前提条件
エージェントにインストールされたAnt
エージェントにインストールされた JDK
特定の OS 用の DigiCert® Software Trust Manager クライアント(クライアントツール)
DigiCert® Software Trust Manager PKSC11ライブラリ (クライアントツール)
Client tools
DigiCert® KeyLocker clients can be downloaded as a package.
Download client tools
In the KeyLocker menu, go to Resources > Client tool repository.
Select your operating system, and then select the corresponding download (
) icon next to the desired client.
Create PKCS11 configuration file
To create a configuration file with the path to the shared library:
Open an integrated development environment (IDE) or plain text editor.
Copy and paste the following text into the editor:
Save the file as pkcs11properties.cfg.
Move the pkcs11properties.cfg file to the same location as the PKCS11 library.
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
KeyLocker enforces multi-factor authentication for security purposes. To access keypairs, certificates, and sign code, you need to set up two types of credentials: An API key and an authentication certificate.
Create an API key
The API key is an authentication method used to verify you as a user and your permissions assigned in DigiCert ONE. The API key provides the first factor authentication.
In DigiCert ONE, select the profile (
) icon, and then select Admin Profile.Under API keys, select Create API key.
For Name, enter a descriptive name for the key.
For End date (optional), enter the date when the key should expire.
Select Create. The API key appears this one time and can't be accessed again. Securely store the API key for future use.
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.
In DigiCert ONE, select the profile (
) icon, and then select Admin Profile.Under Client authentication certificates, select Create client authentication certificate.
For Nickname, enter a descriptive name for the key.
For End date, enter the date when the certificate should expire.
Select the desired Encryption and Signature hash algorithm.
Select Generate certificate. The password appears this one time and can't be accessed again. Download the certificate and securely store the password for future use.
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. |
PKCS11_CONFIG | Provide the path to the PKCS#11 configuration file. |
SM_TLS_SKIP_VERIFY | Enter true to disable or false to enable TLS verification on the client side. |
Secure your credentials
Your DigiCert ONE host environment, API key, client authentication certificate, and password make up your environment variables and are required to access KeyLocker client tools. Use one of the following methods to securely store your credentials based on your operating system.
Sign
To integrate KeyLocker PKCS#11 with Ant, add the following text to the build.xml file:
<project name="pkcs11ant" default="dist" basedir=".">
<description>
sample application
</description>
<!-- set global properties for this build -->
<property name="name" value="pkcs11ant"/>
<property name="src" location="src/main/java" />
<property name="build" location="ant-build" />
<property name="dist" location="${build}" />
<property name="version" value="1.0" />
<property environment="env"/>
<property name="jarfilename" value="${name}-${version}.jar" />
<property name="jarsigner" value="${env.JAVA_HOME}/bin/jarsigner.exe" />
<target name="init">
<!-- Create the time stamp -->
<tstamp />
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}" />
</target>
<target name="compile" depends="init" description="compile the source">
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}" />
</target>
<target name="dist" depends="compile" description="generate the distribution">
<buildnumber />
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib" />
<!-- Put everything in ${build} into the MyApplication-${version}.${build.number}.jar -->
<jar destfile="${dist}/lib/${jarfilename}" basedir="${build}" />
</target>
<target name="sign" depends="dist" description="sign the jar using jarsigner">
<exec executable="${jarsigner}">
<arg line="-providerArg = <path of smpkcs11.config> -keystore NONE -storetype PKCS11 -storepass NONE -providerClass sun.security.pkcs11.SunPKCS11 ${dist}/lib/${jarfilename} <keyPairAlias>,${jarfilename}" />
</exec>
</target>
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
</project>Verify signature
Review the following sample of an Ant setup that verifies a signed JAR:
注記
The single input is the path to the signed jar that needs to be verified.
<property name="jarsigner" value="${env.JAVA_HOME}/bin/jarsigner.exe" />
target name="dist" depends="compile" description="generate the distribution">
<buildnumber />
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib" />
<!-- Put everything in ${build} into the MyApplication-${version}.${build.number}.jar -->
<jar destfile="${dist}/lib/${jarfilename}" basedir="${build}" />
</target>
<target name="verify" depends="dist" description="verify the jar using jarsigner">
<exec executable="${jarsigner}">
<arg line="-verify ${dist}/lib/${jarfilename}" />
</exec>
</target>