可以创建一个 PKCS #12 格式的文件,用于将私钥及其关联的 X.509 证书导出到其他系统。对该文件的访问受口令保护。
% pktool list Found number certificates. 1. (X.509 certificate) Label: label-name ID: fingerprint that binds certificate to private key Subject: subject-DN Issuer: distinguished-name Serial: hex-serial-number 2. ...
使用 pktool list 命令生成的密钥库和标签。为导出文件提供文件名。如果文件名包含空格,需要用双引号将其括起来。
% pktool export keystore=keystore outfile=outfile-name label=label-name
在提示符下键入密钥库的当前口令。此时,即会为导出文件创建口令。接收者在导入该文件时必须提供此口令。
Enter pin for Sun Software PKCS#11 softtoken: Type PIN for token Enter password to use for accessing the PKCS12 file:Create PKCS #12 password
在下面的示例中,用户将私钥及其关联的 X.509 证书导出到一个标准的 PKCS #12 文件中。可将此文件导入到其他密钥库中。PKCS #11 口令可保护源密钥库。PKCS #12 口令用于保护 PKCS #12 文件中的私有数据。导入该文件时需要提供此口令。
% pktool list No. Key Type Key Len. Key Label ---------------------------------------------------- Asymmetric public keys: 1 RSA My Cert Certificates: 1 X.509 certificate Label: My Cert ID: d2:7e:20:04:a5:66:e6:31:90:d8:53:28:bc:ef:55:55:dc:a3:69:93 Subject: C=US, O=My Company, OU=Security Engineering Group, CN=MyCA Issuer: C=US, O=My Company, OU=Security Engineering Group, CN=MyCA Serial: 0x000001
% pktool export keystore=pkcs11 outfile=mydata.p12 label="My Cert" Enter pin for Sun Software PKCS#11 softtoken: Type PIN for token Enter password to use for accessing the PKCS12 file:Create PKCS #12 password
然后,用户打电话给接收者,提供 PKCS #12 口令。