在 Oracle® Solaris 11.2 中管理加密和证书

退出打印视图

更新时间: 2014 年 9 月
 
 

如何将证书导入密钥库

此过程介绍如何将包含以 PEM 或原始 DER 编码的 PKI 信息的文件导入密钥库。有关导出过程的信息,请参见Example 4–4

  1. 导入证书。
    % pktool import keystore=keystore infile=infile-name label=label-name
  2. 如果要导入私有 PKI 对象,需要在系统提示时提供口令。
    1. 在提示符下键入文件的口令。

      如果要导入的是私有 PKI 信息(例如 PKCS #12 格式的导出文件),则需要为该文件提供口令。您要导入的文件的创建者会向您提供 PKCS #12 口令。

      Enter password to use for accessing the PKCS12 file:Type PKCS #12 password
    2. 在提示符下键入密钥库的口令。
      Enter pin for Sun Software PKCS#11 softtoken: Type PIN for token
  3. 检验密钥库的内容。
    % 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. ...
示例 4-2  将 PKCS #12 文件导入密钥库

在下面的示例中,用户从第三方导入了一个 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