此过程介绍如何将包含以 PEM 或原始 DER 编码的 PKI 信息的文件导入密钥库。有关导出过程的信息,请参见Example 4–4。
% pktool import keystore=keystore infile=infile-name label=label-name
如果要导入的是私有 PKI 信息(例如 PKCS #12 格式的导出文件),则需要为该文件提供口令。您要导入的文件的创建者会向您提供 PKCS #12 口令。
Enter password to use for accessing the PKCS12 file:Type PKCS #12 password
Enter pin for Sun Software PKCS#11 softtoken: Type PIN for token
% 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. ...
在下面的示例中,用户从第三方导入了一个 PKCS #12 文件。pktool import 命令可从 gracedata.p12 文件提取私钥和证书,并将它们存储在用户的首选密钥库中。
% pktool import keystore=pkcs11 infile=gracedata.p12 label=GraceCert Enter password to use for accessing the PKCS12 file:Type PKCS #12 password Enter pin for Sun Software PKCS#11 softtoken: Type PIN for token Found 1 certificate(s) and 1 key(s) in gracedata.p12 % pktool list No. Key Type Key Len. Key Label ---------------------------------------------------- Asymmetric public keys: 1 RSA GraceCert Certificates: 1 X.509 certificate Label: GraceCert ID: 71:8f:11:f5:62:10:35:c2:5d:b4:31:38:96:04:80:25:2e:ad:71:b3 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: 0x00000010示例 4-3 将 X.509 证书导入密钥库
在下面的示例中,用户将 PEM 格式的 X.509 证书导入用户的首选密钥库。此公共证书不受口令保护。用户的公共密钥库也不受口令保护。
% pktool import keystore=pkcs11 infile=somecert.pem label="TheirCompany Root Cert" % pktool list No. Key Type Key Len. Key Label Certificates: 1 X.509 certificate Label: TheirCompany Root Cert ID: ec:a2:58:af:83:b9:30:9d:de:b2:06:62:46:a7:34:49:f1:39:00:0e Subject: C=US, O=TheirCompany, OU=Security, CN=TheirCompany Root CA Issuer: C=US, O=TheirCompany, OU=Security, CN=TheirCompany Root CA Serial: 0x00000001