Java Solaris 加入Sun中国技术社区 我的社区 注册说明

BigAdmin 系统管理门户网站
Feature hub articles
BigAdmin 专题文章:在使用 UltraSPARC T1 处理器的系统上配置 Sun Java System Messaging Server 6.3 和 Solaris 加密框架

在使用 UltraSPARC T1 处理器的系统上配置 Sun Java System Messaging Server 6.3 和 Solaris 加密框架

Durga Tirunagari,2006 年 12 月

本文介绍如何为 SSL 配置 Sun Java System Messaging Server 6.3 以及如何配置 Solaris 加密框架 (Solaris Cryptographic Framework, SCF),以使用 UltraSPARC T1 处理器的加密加速器。此过程分为三步:为 SSL 配置 Messaging Server(可选)、配置 Solaris 加密框架以及配置 Messaging Server 以使用 SCF。


本文中讨论的组件简介

本部分介绍本文中讨论的组件。

关于 Sun Java System Messaging Server

Sun Java System Messaging Server 是一个高性能、高安全性的消息传送平台。Messaging Server 用户从数千个到数百万个不等,它适用于对合并电子邮件服务器和降低通信基础结构的总拥有成本感兴趣的服务提供者和企业。Messaging Server 还提供了大量安全性功能,这些功能通过用户验证、会话加密以及相应内容过滤(有助于防范垃圾邮件和病毒)来帮助确保通信的完整性。安全性是 Messaging Server 非常重要的一个方面。有关 Messaging Server 和其他 Communications Suite 产品的详细信息,请参见 http://www.sun.com/bigadmin/hubs/comms

关于 Solaris 加密框架

Solaris 加密框架 (Solaris Cryptographic Framework, SCF) 提供了算法和 PKCS#11 库的公用存储库,以处理加密要求。PKCS#11 库是按照 RSA Security Inc. 制订的 PKCS#11 加密令牌接口 (Cryptographic Token Interface, Cryptoki) 加密标准实现的。有关详细信息,请参见《Solaris Security for Developers Guide》中的 Chapter 8, Introduction to the Solaris Cryptographic Framework(第 8 章“Solaris 加密框架简介”)Further Reading(补充读物)。Solaris 10 操作系统和 Solaris Express 发行版本中都提供了 Solaris 加密框架。

PKCS#11 模块(也称为加密模块或加密服务提供程序)用于管理加密服务,如通过 PKCS#11 接口进行的加密和解密。可以将 PKCS#11 模块视为可在软件或硬件中实现的加密设备驱动程序。PKCS#11 模块始终包含一个或多个插槽,可将其视为某种形式的物理读取器中的物理硬件插槽(例如,用于智能卡)或概念性软件插槽。PKCS#11 模块的每个插槽又可以包含令牌,令牌是实际提供加密服务以及存储证书和密钥(可选)的硬件或软件设备。硬件令牌是指在物理设备(如硬件加速器和智能卡)中实现的 PKCS#11 令牌。软件令牌是指完全在软件中实现的 PKCS#11 令牌。

可以将 Messaging Server 配置为使用 NSS 内置软件令牌来满足加密需要。任何支持 PKCS#11 的 PKCS#11 模块均可以与 NSS 库一起使用,因此,Solaris 加密框架可以用作 Messaging Server 的加密服务提供程序。

关于 UltraSPARC T1 处理器

非对称加密通常也称为公钥基础结构 (Public Key Infrastructure, PKI) 加密。PKI 加密占用的 CPU 资源最多比对称加密高 1000 倍。Rivest-Shamir-Adelman (RSA) 算法使用模运算来启用公钥和私钥的概念。通常,仅将使用公钥加密的 RSA 运算卸载到硬件加速器。因此,加速器卡执行非对称加密运算;而对称加密运算是由服务器的主处理器执行的。

RSA 运算是 SSL 完整握手过程的重要组成部分。UltraSPARC T1 处理器的每个核心都包含一个 MAU(Modular Arithmetic Unit,模运算单元),它支持 RSA 和 DSA 运算。RSA 运算使用一种计算密集型算法,可以将其卸载到 MAU。MAU 每秒能够保持 14000 次 RSA 运算。通过将 RSA 运算移到 MAU,可以加快完整握手过程的进行并减轻 CPU 负担。按照 Solaris 加密框架,MAU 是作为服务提供程序(ncp(7D)-Niagara 加密提供程序设备驱动程序)实现的。使用硬件加速器可以显著提高性能。


高级概述

要将 Messaging Server 配置为使用 UltraSPARC T1 处理器的 Sun 加密加速器,需要执行以下高级操作:

  1. 为 SSL 配置 Messaging Server
  2. 为 SSL 配置各个 Messaging Server 进程(服务器)
  3. 为 Messaging Server 配置 Solaris 加密框架 (Solaris Cryptographic Framework, SCF)
  4. 将 Messaging Server 配置为使用外部令牌
  5. 启动 Messaging Server 服务
  6. 验证 SCF 是否正常运行

为 SSL 配置 Messaging Server

本部分介绍用于创建 secmodkey3cert8 数据库、获取证书以及为 NSS 内置软件令牌安装证书的过程。通过完成这些过程,可以在 Messaging Server 部署上启用 SSL。

如果已经为 SSL 配置了 Messaging Server 部署,请跳过本部分并转到为 SSL 配置各个 Messaging 进程


关于 msgcert 命令

msgcert 命令是用于管理证书的主要机制。它允许生成证书请求、将证书添加到证书数据库以及列出证书数据库中的证书等。msgcert 命令(类似于所有 Messaging Server 命令)作为 mailsrv 运行。因此,即使您以 root 身份执行 msgcert,它也会作为 Messaging Server 用户执行。msgcert 实用程序位于 Messaging-Server-Root/sbin 目录中,其中 Messaging-Server-Root 是 Messaging Server 的安装位置,缺省情况下为 /opt/SUNWmsgsr

要获取 msgcert 命令的详细信息,请键入:

Messaging-Server-Root/sbin/msgcert --help

创建证书数据库和添加证书/密钥对

以下过程生成 secmodkey3cert8 数据库,并且还创建了 sslpassword.conf 文件。缺省情况下,证书是在 Messaging-Server-Root/config 目录中生成的。

也可以使用以下配置 local.ssldbprefix 参数指定证书数据库的位置和前缀。

Messaging Server 用户(如 mailsrv)应该能够在 local.ssldbpath 中读取和写入数据。

  1. 转至 Messaging Server sbin 目录。
    cd Messaging-Server-Root/sbin

  2. 运行以下命令:
    ./msgcert generate-certDB

    此实用程序将提示您输入口令以保护证书数据库中的密钥和证书。

  3. 选择证书数据库口令。(该口令未回显在屏幕上)。
  4. 确认证书数据库口令。(该口令未回显在屏幕上)。
  5. 确认已创建所需的数据库和 sslpassword.conf 文件。
    # ls -lrt ../config/*.db ../config/sslpassword.conf
    -rw-------   1 mailsrv  mail       32768 Nov 16 04:40 ../config/secmod.db
    -rw-------   1 mailsrv  mail       65536 Nov 16 04:40 ../config/cert8.db
    -rw-------   1 mailsrv  mail       32768 Nov 16 04:40 ../config/key3.db
    -rw-r-----   1 mailsrv  mail          36 Nov 16 04:40 ../config/sslpassword.conf
    
    # cat ../config/sslpassword.conf
    Internal (Software) Token:12345678

获取证书

缺省情况下,msgcert 命令会创建一个别名为 Server-Certself-signed-certificate。您可以删除或使用此 self-signed-certificate

以下示例说明了如何删除此缺省 self-signed-certificate

./msgcert remove-cert -W Messaging-Server-Root/config/sslpassword Server-Cert

  1. 请求 CA 签名的服务器证书。

    对于 msgcert request-cert 命令,请将 cert 请求指定为 ASCII 格式(缺省为二进制文件)。生成的证书请求是采用保密性增强的电子邮件 (Privacy Enhanced Mail, PEM) 格式的 PKCS#10 证书请求。PEM 是由 RFC 1421 至 1424 (RFC 1421) 指定的格式,用于以 US-ASCII 字符表示采用 base64 编码的证书请求。

    例如:

    # echo "12345678" > Messaging-Server-Root/config/sslpassword

    注:此口令与用于生成证书数据库的口令相同。

    # ./msgcert request-cert  -W Messaging-Server-Root/config/sslpassword
    --name "foobar.siroe.com" --org "Development" --org-unit "Comms" --city
    Santaclara --state California --country us -F ascii -o /tmp/MyCertRequest

    证书签名请求 (Certificate Signing Request, CSR) 的内容与以下内容相类似:

    # cat /tmp/MyCertRequest
    
    -----BEGIN NEW CERTIFICATE REQUEST-----
    MIIBvzCCASgCAQAwfzELMAkGA1UEBhMCdXMxEzARBgNVBAgTCkNhbGlmb3JuaWEx
    EzARBgNVBAcTClNhbnRhY2xhcmExDjAMBgNVBAsTBWNvbW1zMRQwEgYDVQQKEwtE
    ZXZlbG9wbWVudDEgMB4GA1UEAxMXYmlvdGl0ZS5yZWQuaXBsYW5ldC5jb20wgZ8w
    DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALFCDfmu1uYFy3DtHAo/kJUFqXF6utq2
    ga+Tow2PNEyuX+70SqyZ0vFwiL8di9b1mLMHLp3WBDPmXjVfNkANHk6Q38RlfyzT
    7iYpvhi6+4OVthzC65FaqwnEEiodZ7z7yx8vRhj4lVxeoNJpJexGr1MHuYr8tobe
    ljgEmrLP17aNAgMBAAGgADANBgkqhkiG9w0BAQQFAAOBgQANzqjEwcnnmdXjo/KH
    buolHi1hNEYoDsXWIlTi78xkH+7gtfCPkymFzTy5mS58PzAqyWm81MZKXj39C+Eq
    DOCJmZYRt3lG6wo0M8nMoQLHsVSHfGZxOyppupzYsmVfszhczr0EEHJP66itDPW2
    /jHGRbhXfeJNhKsisscd/YYkEQ==
    -----END NEW CERTIFICATE REQUEST-----

  2. 按照程序将 CSR 传送到证书颁发机构。

    用于获取证书颁发机构证书的过程因所使用的证书颁发机构而异。某些商业 CA 提供一个 Web 站点,您可以从中自动下载证书。其他 CA 根据请求通过电子邮件将证书发送给您。发送请求之后,您必须等待 CA 使用证书进行响应。

  3. 保存从证书颁发机构收到的证书。

    您应该在安全位置备份证书。如果以前丢失了证书,可使用备份文件重新安装证书。您可以将证书作为文本文件进行保存。采用 PEM 格式的 PKCS#11 证书类似于以下内容:

    -----BEGIN CERTIFICATE-----
    MIIDmTCCAwKgAwIBAgIBZjANBgkqhkiG9w0BAQQFADCBhjELMAkGA1UEBhMCVVMx
    EzARBgNVBAgTCkNhbGlmb3JuaWExDzANBgNVBAoTBlNTRS1TVzEPMA0GA1UECxMG
    UG9ydGFsMRgwFgYDVQQDEw9WZWVyYSBOYXRhcmFqYW4xJjAkBgkqhkiG9w0BCQEW
    F3ZlZXJhLm5hdGFyYWphbkBzdW4uY29tMB4XDTA2MTExNjA3MDIyN1oXDTA3MTEx
    NjA3MDIyN1owfzELMAkGA1UEBhMCdXMxEzARBgNVBAgTCkNhbGlmb3JuaWExEzAR
    BgNVBAcTClNhbnRhY2xhcmExFDASBgNVBAoTC0RldmVsb3BtZW50MQ4wDAYDVQQL
    EwVjb21tczEgMB4GA1UEAxMXYmlvdGl0ZS5yZWQuaXBsYW5ldC5jb20wgZ8wDQYJ
    KoZIhvcNAQEBBQADgY0AMIGJAoGBALFCDfmu1uYFy3DtHAo/kJUFqXF6utq2ga+T
    ow2PNEyuX+70SqyZ0vFwiL8di9b1mLMHLp3WBDPmXjVfNkANHk6Q38RlfyzT7iYp
    vhi6+4OVthzC65FaqwnEEiodZ7z7yx8vRhj4lVxeoNJpJexGr1MHuYr8tobeljgE
    mrLP17aNAgMBAAGjggEbMIIBFzAJBgNVHRMEAjAAMDUGCWCGSAGG+EIBDQQoFiZT
    dW5PTkUtUFRTIFBvcnRhbDogT3BlblNTTCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQU
    wkhhgKwbt1P8SXrRHpesVuhel0gwgbMGA1UdIwSBqzCBqIAUIALOde3lgiZiUwXo
    PTiN/YaJKoihgYykgYkwgYYxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9y
    bmlhMQ8wDQYDVQQKEwZTU0UtU1cxDzANBgNVBAsTBlBvcnRhbDEYMBYGA1UEAxMP
    VmVlcmEgTmF0YXJhamFuMSYwJAYJKoZIhvcNAQkBFhd2ZWVyYS5uYXRhcmFqYW5A
    c3VuLmNvbYIBADANBgkqhkiG9w0BAQQFAAOBgQAdsOxEygD/Rbj4NWHhTrAZcn2B
    mWv40MFS1oAgJSMc5BPTBGHcSnnLEh0ZApFLfWknVro4ubW3mb5ByaHoR3sOsxAO
    4705avDUgX2g+4V80ef2CVOo5AoZRNMgVMt4Ju3D1PDZsDWQstbfV3PTeMyAzy/7
    NZh1+adCuh8J+Rhl4Q==
    -----END CERTIFICATE-----

  4. 执行上述步骤以获取其他证书。

将证书添加到 NSS 软件令牌中

  1. 将签名证书保存到临时位置,例如,/tmp/caissuedFirstCert

    在本示例中,第二个签名证书也是使用上述过程获取的,并被保存为 /tmp/caissuedSecondCert

  2. 安装 CA 签名的服务器证书。
    ./msgcert add-cert  -W Messaging-Server-Root/config/sslpassword Server-Cert \
          /tmp/caissuedFirstCert
    
    ../msgcert add-cert  -W Messaging-Server-Root/config/sslpassword SolCrypto-Framework \
          /tmp/caissuedSecondCert

  3. 对于已获取的其他证书重复步骤 1 和 2。
  4. 验证是否成功安装了这些证书。
    #./msgcert list-certs -W Messaging-Server-Root/config/sslpassword
    ....
    2 certificates found


为 SSL 配置各个 Messaging 进程

本部分介绍用于为 SSL 配置各个 Messaging Server 进程的过程。

为 SSL 配置 MMP

  1. 设置 SSL 证书别名。

    按如下方式编辑 ImapProxyAService.cfgPopProxyAService.cfg 文件,以将 default:SSLCertNickNames 行修改为 "Server-Cert"

    # cd Messaging-Server-Root/data/config
    ImapProxyAService.cfg: default:SSLCertNicknames  "Server-Cert"
    PopProxyAService.cfg:  default:SSLCertNicknames  "Server-Cert"

  2. 要启用 SSL 和 IMAP,请编辑 ImapProxyAService.cfg 文件,并取消对相关 SSL 设置的注释。

    ImapProxyAService.cfg 样例文件类似于以下内容:

    # SSL configuration
    #
    #  Enable SSL from client to MMP with this:
    default:SSLEnable         yes
    default:SSLPorts         993
    default:SSLCertNicknames  Server-Cert
    #  Password File for SSL server keys:
    default:SSLKeyPasswdFile <Messaging_Server_Root>/config/sslpassword.conf
    #  Where SSL session cache, secmod, cert, and key files are located:
    default:SSLCacheDir      <Messaging_Server_Root>/config
    #  Customizable SSL security module database file name:
    default:SSLSecmodFile     secmod.db
    #  Customizable SSL cert7.db and key3.db file prefixes:
    default:SSLCertPrefix     ""
    default:SSLKeyPrefix      ""
    #  Use SSL on this port when talking to the backend server (0 = don't use SSL)
    default:SSLBacksidePort   993
    default:ServiceList  /opt/SUNWmsgsr/lib/ImapProxyAService@1143|1993
    /opt/SUNWmsgsr/lib/PopProxyAService@1110|1995

  3. 要启用 SSL 和 POP,请编辑 PopProxyAService.cfg 文件,并取消对相关 SSL 设置的注释。
  4. 编辑 AService.cfg 文件。对于 SSL 和 POP,在 ServiceList 设置中的 1110 后面添加 |1995。对于 SSL 和 IMAP,在 1143 后面添加 |1993

    AService.cfg 文件应该类似于以下内容:

    default:ServiceList  /opt/SUNWmsgsr/lib/ImapProxyAService@1143|1993
    /opt/SUNWmsgsr/lib/PopProxyAService@1110|1995

为 SSL 配置 IMAP

  1. 可以使用 configutil 命令设置以下配置参数以启用 SSL:
    ./configutil -o service.imap.enablesslport -v yes
    ../configutil -o service.imap.enable -v 1
    ../configutil -o service.imap.sslport -v 993
    ../configutil -o service.imap.sslusessl -v yes

  2. 可以使用 configutil 命令来设置 SSL 证书别名:
    ./configutil -o encryption.rsa.nssslpersonalityssl -v "Server-Cert"

为 SSL 配置 POP

  1. 可以使用 configutil 命令设置以下配置参数以启用 SSL:
    ./configutil -o service.pop.enable -v 1
    ../configutil -o service.pop.enablesslport -v yes
    ../configutil -o service.pop.sslport -v 995
    ../configutil -o service.pop.sslusessl -v yes

  2. 可以使用 configutil 命令来设置 SSL 证书别名:
    ./configutil -o encryption.rsa.nssslpersonalityssl -v "Server-Cert"

为 SSL 配置 HTTP

  1. 可以使用 configutil 命令设置以下配置参数以启用 SSL:
    ./configutil -o service.http.enable -v 1
    ../configutil -o service.http.enablesslport -v yes
    ../configutil -o service.http.sslport -v 443
    ../configutil -o service.http.sslusessl -v yes

  2. 可以使用 configutil 命令来设置 SSL 证书别名:
    ./configutil -o encryption.rsa.nssslpersonalityssl -v "Server-Cert"

为 SSL 配置 SMTP

  1. 可以使用 configutil 命令来设置 SSL 证书别名:
    ./configutil -o encryption.rsa.nssslpersonalityssl -v "Server-Cert"

  2. 要为传出消息启用 SSL 加密,请修改通道定义以包含 TLS 通道关键字,如 maytlsmusttls 等。
  3. 如果要在备用端口上支持 SSL,请取消对 TLS_PORT 条目(在位于 Messaging-Server-Root/config 目录的 dispatcher.cnf 文件中)的注释。

    例如:

    port 465
    TLS_PORT=465

    注:也可以使用针对每个服务的 SSL 证书别名配置设置。具有相同含义(即别名)并覆盖 encryption.rsa.sslpersonalityssl 设置的配置参数为:

    • local.imta.sslnicknames(用于 SMTP 和提交服务器)
    • local.imap.sslnicknames(用于 IMAP 服务器)
    • local.pop.sslnicknames(用于 POP 服务器)
    • local.http.sslnicknames(用于 HTTP 服务器)

验证 SSL 配置

  1. 可以使用 netstat 命令来验证服务是否正在运行。

    例如:

    netstat -an | grep service.service.sslport

    其中 servicemmpimappophttpsmtp 关键字。

  2. 检查 Messaging Server 日志文件中是否存在错误。

    日志文件位于 Messaging-Server-Root/log 目录中。例如,检查 imap 日志以确保没有 SSL 初始化错误(ASockSSL_Init 错误)。


配置 Solaris 加密框架 (Solaris Cryptographic Framework, SCF)

由于 Solaris 加密框架软件令牌包含私人信息,因此应使用 pktool(1) 命令在该令牌上设置口令。此命令可以初始化用户的缺省密钥库,方法是作为应用程序所有者(Messaging Server 用户)登录系统。

设置 SCF 软件令牌 Pin

运行 pktool setpin 命令可初始化 $HOME/.sunw/pkcs11_softtoken/ 目录中的软件令牌数据存储库。只有所有者能够访问创建的这些文件以保护其内容。这也意味着,您需要作为用于运行 Messaging Server 的相同用户(即 mailsrv)来执行初始化,因此,此用户有权访问正确的数据存储库。

  1. 成为 mailsrv 用户。
    su mailsrv

  2. 运行 id 命令。
    $ id
    
    uid=207023(mailsrv) gid=6(mail)

  3. 运行 pktool 命令。
    $ pktool setpin

  4. 创建新的口令短语。(该口令短语未回显在屏幕上。)

    可以使用此口令短语将证书/密钥对导入 SCF 令牌。

  5. 重新输入该口令短语。(该口令短语未回显在屏幕上。)

    系统将通知您该口令短语已更改。

  6. 转至 /export/mailsrv 目录。
    cd /export/mailsrv

  7. 检查权限。
    $ ls -alrR
    ..:
    total 6
    drwx------   3 mailsrv  mail         512 Nov 16 17:21 .sunw
    drwxr-xr-x   4 root     sys          512 Oct 31 12:31 ..
    drwxrwxrwx   3 root     root         512 Nov 16 17:21 .
    
    ../.sunw:
    total 6
    drwx------   4 mailsrv  mail         512 Nov 16 17:21 pkcs11_softtoken
    drwxrwxrwx   3 root     root         512 Nov 16 17:21 ..
    drwx------   3 mailsrv  mail         512 Nov 16 17:21 .
    
    ../.sunw/pkcs11_softtoken:
    total 10
    drwx------   2 mailsrv  mail         512 Nov 16 17:21 public
    drwx------   2 mailsrv  mail         512 Nov 16 17:21 private
    -rw-------   1 mailsrv  mail         103 Nov 16 17:21 objstore_info
    drwx------   3 mailsrv  mail         512 Nov 16 17:21 ..
    drwx------   4 mailsrv  mail         512 Nov 16 17:21 .
    
    ../.sunw/pkcs11_softtoken/public:
    total 4
    drwx------   4 mailsrv  mail         512 Nov 16 17:21 ..
    drwx------   2 mailsrv  mail         512 Nov 16 17:21 .
    
    ../.sunw/pkcs11_softtoken/private:
    total 4
    drwx------   4 mailsrv  mail         512 Nov 16 17:21 ..
    drwx------   2 mailsrv  mail         512 Nov 16 17:21 .

使用 cryptoadm 管理加密框架

cryptoadm 实用程序显示系统的加密提供程序信息、为每个提供程序配置机制,以及安装或卸载加密提供程序。Solaris 加密框架支持三种类型的提供程序:用户级提供程序(PKCS#11 共享库)、内核提供程序(可装入的内核软件模块)以及内核硬件提供程序(加密硬件设备)。cryptoadm 实用程序提供了一些子命令,用于启用和禁用 metaslot 功能、列出 metaslot 配置以及配置 metaslot 机制策略。

  1. 可通过运行 cryptoadm list -m 列出 Solaris 加密框架中的所有服务提供程序及其加密机制。请验证 ncppkcs11_softtoken.so 是否可用作加密提供程序。由于 NCP 是内核提供程序,因此 pkcs11_kernel.so 在输出中应该位于 pkcs11_softtoken.so 前面。

    以下是此命令的部分输出内容。

    # cryptoadm list -m
    
    User-level providers:
    =====================
    Provider: /usr/lib/security/$ISA/pkcs11_kernel.so
    Mechanisms:
    CKM_DSA
    CKM_RSA_X_509
    CKM_RSA_PKCS
    
    Provider: /usr/lib/security/$ISA/pkcs11_softtoken.so
    Mechanisms:
    CKM_DES_CBC
    CKM_DES_CBC_PAD
    CKM_DES_ECB
    CKM_DES_KEY_GEN
    [.... so on ...]
    CKM_DSA
    CKM_DSA_SHA1
    CKM_DSA_KEY_PAIR_GEN
    [.... so on ...]
    CKM_TLS_MASTER_KEY_DERIVE_DH
    CKM_SSL3_KEY_AND_MAC_DERIVE
    CKM_TLS_KEY_AND_MAC_DERIVE
    CKM_TLS_PRF
    
    Kernel software providers:
    ==========================
    des: CKM_DES_ECB,CKM_DES_CBC,CKM_DES3_ECB,CKM_DES3_CBC
    aes: CKM_AES_ECB,CKM_AES_CBC,CKM_AES_CTR
    [.... so on ...]
    sha1: CKM_SHA_1,CKM_SHA_1_HMAC,CKM_SHA_1_HMAC_GENERAL
    md5: CKM_MD5,CKM_MD5_HMAC,CKM_MD5_HMAC_GENERAL
    rsa:CKM_RSA_PKCS,CKM_RSA_X_509,CKM_MD5_RSA_PKCS,CKM_SHA1_RSA_PKCS,CKM_SHA256_RSA_PKCS,
    CKM_SHA384_RSA_PKCS,CKM_SHA512_RSA_PKCS
    swrand: No mechanisms presented.
    
    Kernel hardware providers:
    ==========================
    ncp/0: CKM_DSA,CKM_RSA_X_509,CKM_RSA_PKCS

  2. 禁止使用以下用户级机制,强制由 NCP 执行这些机制。
    # cryptoadm disable provider=/usr/lib/security/'$ISA'/pkcs11_softtoken.so \
    mechanism=CKM_SSL3_PRE_MASTER_KEY_GEN,\
    CKM_SSL3_MASTER_KEY_DERIVE,CKM_SSL3_KEY_AND_MAC_DERIVE,CKM_SSL3_MASTER_KEY_DERIVE_DH,\
    CKM_SSL3_MD5_MAC,CKM_SSL3_SHA1_MAC

  3. 验证是否禁用了用户级机制。
    # cryptoadm list -p provider=/usr/lib/security/'$ISA'/pkcs11_softtoken.so
    /usr/lib/security/$ISA/pkcs11_softtoken.so: all mechanisms are enabled,
    except CKM_SSL3_SHA1_MAC,CKM_SSL3_MD5_MAC,CKM_SSL3_MASTER_KEY_DERIVE_DH,
    CKM_SSL3_KEY_AND_MAC_DERIVE,CKM_SSL3_MASTER_KEY_DERIVE,
    CKM_SSL3_PRE_MASTER_KEY_GEN. random is enabled.

配置 SCF 提供程序

NSS 使用 secmod.db 跟踪可用的 PKCS#11 模块。您可以使用安全模块数据库工具 modutil,这是一个随 NSS 提供的 CLI,用于管理 secmod.db 文件中的 PKCS#11 模块信息。使用安全模块数据库工具可以添加和删除 PKCS#11 模块、更改口令、设置缺省值、列出模块内容以及启用或禁用插槽。modutil CLI 与 Messaging Server 软件捆绑在一起,它位于 Messaging-Server-Root/sbin 目录中。本示例假定从 Messaging-Server-Root/sbin 目录中运行 modutil,并且 cert8.dbsecmod.dbkey3.db 均位于 config 目录(即 Messaging-Server-Root/config)下面。

  1. 列出所有可用的 PKCS#11 模块。

    通过使用 modutil,您可以列出所有可用的 PKCS#11 模块。缺省情况下,NSS 具有一个内部的 PKCS#11 模块。

    #./modutil -dbdir ../config -nocertdb -list
    
    Using database directory ../config...
    Listing of PKCS #11 Modules
    -----------------------------------------------------------
      1. NSS Internal PKCS #11 Module
         slots: 2 slots attached
         status: loaded
    
         slot: NSS Internal Cryptographic Services
         token: NSS Generic Crypto Services
    
         slot: NSS User Private Key and Certificate Services
         token: NSS Certificate DB

  2. 列出缺省 NSS 软件令牌的内容。

    sslpassword 文件包含证书数据库的口令。

    # ./msgcert list-certs -W Messaging-Server-Root/config/sslpassword
    
    Alias Valid from Expires on Self-signed?Issued by Issued to
    
    Server-Cert           2006/11/15 23:02     2007/11/15 23:02   n
    CN=CA,OU=test,O=authority,ST=California,C=US
    CN=foobar.siroe.com,OU=comms,O=Dev,L=Santaclara,ST=California,C=us
    SolCrypto-Framework  2006/11/16 00:14  2007/11/16 00:14        n
    CN=CA,OU=test,O=authority,ST=California,C=US
    CN=SCF,OU=comms,O=Dev,L=Santaclara,ST=California,C=us
    2 certificates found

将 Solaris 加密框架作为服务提供程序进行添加

可以将 Messaging Server 配置为使用 NSS 内置软件令牌来满足其加密需要,它使用 PKCS#11 访问加密功能。通过链接到 /usr/lib/libpkcs11.so 库获取对 PKCS#11 功能的直接访问,可以修改 Messaging Server 配置以使用 Solaris 加密框架的全新用户级加密框架。也就是说,将 Solaris 加密框架注册为 PKCS#11 模块。

  1. 在 Messaging Server 软件中注册 /usr/lib/libpkcs11.so PKCS#11 库并启用名为 Sun Metaslot 的插槽。
    # ./modutil -dbdir ../config/ -nocertdb -add "Solaris Crypto Framework" -libfile
    /usr/lib/libpkcs11.so -mechanisms RSA
    
    WARNING: Performing this operation while the browser is running could cause corruption
    of your security databases.If the browser is currently running,
    you should exit browser before continuing this operation.Type 'q <enter>' to abort,
    or <enter> to continue:
    
    Using database directory ../config...
    
    Module "Solaris crypto Framework" added to database.

  2. 继续执行下一个任务。

启用名为 Sun Metaslot 的插槽

  1. 运行以下 modutil 命令。
    # ./modutil -dbdir ../config/ -nocertdb -disable "Solaris Crypto Framework"
    
    WARNING: Performing this operation while the browser is running
    could cause corruption of your security databases.
    If the browser is currently running,
    you should exit browser before continuing this operation.
    Type 'q <enter>' to abort, or <enter> to continue:
    Using database directory ../config...
    
    Slot "Sun Metaslot" disabled.
    Slot "ncp/0 Crypto Accel Asym 1.0" disabled.

  2. 运行以下 modutil 命令。
    # ./modutil -dbdir ../config/ -nocertdb -enable "Solaris Crypto Framework" -slot "Sun Metaslot"
    WARNING: Performing this operation while the browser is running
    could cause corruption of your security databases.
    If the browser is currently running,
    you should exit browser before continuing this operation.
    Type 'q <enter>' to abort, or <enter> to continue:
    
    Using database directory ../config...
    Slot "Sun Metaslot" enabled.

  3. 运行以下 modutil 命令,验证是否成功添加了 Solaris 加密框架。
    # ./modutil -dbdir ../config/ -nocertdb -list
    
    Using database directory ../config...
    
    Listing of PKCS #11 Modules
    -----------------------------------------------------------
      1. NSS Internal PKCS #11 Module
    
         slots: 2 slots attached
         status: loaded
    
         slot: NSS Internal Cryptographic Services
         token: NSS Generic Crypto Services
    
         slot: NSS User Private Key and Certificate Services
         token: NSS Certificate DB
    
      2. Solaris crypto Framework
    
         library name: /usr/lib/libpkcs11.so
    
         slots: 2 slots attached
         status: loaded
    
         slot: Sun Metaslot
         token: Sun Metaslot
    
         slot: ncp/0 Crypto Accel Asym 1.0
         token: ncp/0 Crypto Accel Asym 1.0
    -----------------------------------------------------------

从 NSS 软件令牌中导出证书/密钥对

此任务介绍如何从 NSS 软件令牌中导出证书/密钥对(作为 PKCS#12 格式的文件),以将其导入到 SCF 软件令牌中。下面说明了如何导出位于内部令牌中的两个证书。

  1. 选择 PKCS#12 文件口令,并将其复制到名为 /tmp/pkcs12password 的文件中。
    # echo "pkcspassword" > /tmp/pkcs12password

  2. 运行以下命令,将位于内部令牌中的两个证书导出到 PKCS#12 格式的文件中。
    # ./msgcert export-cert -W Messaging-Server-Root/config/sslpassword \
    -o /tmp/Server-Certpk12 -O /tmp/pkcs12password Server-Cert
    
    # file /tmp/Server-Certpk12
    
    /tmp/Server-Certpk12:   data

  3. 继续执行下一个任务。

将密钥/证书对导入到 Sun Metaslot (SCF) 中

  1. 运行以下 pk12util 命令。
    $ ./pk12util -i /tmp/Server-Certpk12 -d ../config/ -h "Sun Metaslot"
    
    Enter Password or Pin for "Sun Metaslot":
    { This is the same password you entered, when running pktool setpin )
    Enter password for PKCS12 file:
    {PKCSpassword : password used to export certificates from the Internal Software Token }
    pk12util: PKCS12 IMPORT SUCCESSFUL

  2. 运行以下 pk12util 命令。
    $  ./pk12util -i /tmp/SCFpk12 -d ../config/ -h "Sun Metaslot"
    
    Enter Password or Pin for "Sun Metaslot":
    { This is the same password you entered, when running pktool setpin )
    Enter password for PKCS12 file:
    {PKCSpassword : password used to export certificates from the Internal Software Token }
    pk12util: PKCS12 IMPORT SUCCESSFUL

  3. 继续执行下一个任务。

验证是否成功导入了证书/密钥对

可以使用此任务来验证是否成功将证书/密钥对导入到令牌中。您必须以 mailsrv(即,Messaging Server 用户)身份登录。

  1. 运行以下 certutil 命令。
    $ ./certutil -L -d ../config/ -h "Sun Metaslot"
    
    Enter Password or Pin for "Sun Metaslot":
    ( This is the same password you entered, when running pktool setpin. )
    Sun Metaslot:Server-Cert                                       u,u,u
    Sun Metaslot:SolCrypto-Framework                               u,u,u

  2. 运行以下 certutil 命令。
    $ ./certutil -K -d ../config/ -h "Sun Metaslot"
    
    Enter Password or Pin for "Sun Metaslot":
    ( This is the same password you entered, when running pktool setpin. )
    <0> Server-Cert
    <1> SolCrypto-Framework

  3. 转至下一部分以配置 Messaging Server。

将 Messaging Server 配置为使用外部令牌

本部分介绍用于将各个 Messaging Server 进程配置为使用外部令牌的过程。

将 Messaging Server 进程配置为使用外部令牌

  1. 按如下方式编辑 ImapProxyAService.cfgPopProxyAService.cfg 文件以配置 MMP。
    # cd Messaging-Server-Root/data/config
    ImapProxyAService.cfg: default:SSLCertNicknames  "Sun Metaslot:Server-Cert"
    PopProxyAService.cfg:  default:SSLCertNicknames   "Sun Metaslot:Server-Cert"

  2. 通过设置以下配置参数,将 IMAP 服务器配置为使用外部令牌。
    ./configutil -o encryption.rsa.nssslpersonalityssl -v "Sun Metaslot:Server-Cert"
    或
    ../configutil -o local.imap.sslnicknames -v "Sun Metaslot:Server-Cert"

  3. 通过设置以下配置参数,将 POP 服务器配置为使用外部令牌。
    ./configutil -o encryption.rsa.nssslpersonalityssl -v "Sun Metaslot:Server-Cert"
    或
    ../configutil -o local.pop.sslnicknames -v "Sun Metaslot:Server-Cert"

  4. 通过设置以下配置参数,将 HTTP 服务器配置为使用外部令牌。
    # ./configutil -o encryption.rsa.nssslpersonalityssl -v "Sun Metaslot:Server-Cert"
    或
    # ./configutil -o local.http.sslnicknames -v "Sun Metaslot:Server-Cert"

  5. 通过设置以下配置参数,将 SMTP 服务器配置为使用外部令牌。

    可以使用 configutil 命令来设置 SSL 证书别名:

    ./configutil -o encryption.rsa.nssslpersonalityssl -v "Sun Metaslot:Server-Cert"
    或
    ../configutil -o local.imta.sslnicknames -v "Sun Metaslot:Server-Cert"

    注:如上所示,也可以使用针对每个服务的 SSL 证书别名配置设置。具有相同含义(即别名)并覆盖 encryption.rsa.sslpersonalityssl 设置的配置参数为:

    • local.imta.sslnicknames(用于 SMTP 和提交服务器)
    • local.imap.sslnicknames(用于 IMAP 服务器)
    • local.pop.sslnicknames(用于 POP 服务器)
    • local.http.sslnicknames(用于 HTTP 服务器)

  6. 将 "Sun Metaslot" 口令保存在 sslpassword.conf 文件中。

    "Sun Metaslot" 受口令保护。每次启动时,服务器都会提示您输入口令。Messaging Server 从位于 Messaging-Server-Root/config 目录的 sslpassword.conf 文件中读取口令,而不是每次都输入口令。请按如下方式编辑此文件。

    # cat Messaging-Server-Root/data/config/sslpassword.conf
    Sun Metaslot:secret
    ( "secret" : This is the same password you entered, when running pktool setpin )

启动并调试 Messaging Server 服务

此任务说明如何重新启动 Messaging Server 服务、检查错误以及验证 SCF 环境是否正常运行。

  1. 重新启动 Messaging Server 服务。
    # Messaging-Server-Root/sbin/start-msg
    Connecting to watcher ...
    Launching watcher ... 27351
    Starting ens server ... 27352
    Starting store server .... 27353
    Checking store server status .... ready
    Starting imap server .... 27354
    Starting pop server .... 27355
    Starting http server .... 27356
    Starting sched server ... 27357
    Starting dispatcher server .... 27359
    Starting job_controller server .... 27365

  2. 确保日志文件中不包含 SSL_init 错误,并且 tcp_smptdefaultimappophttp 日志文件均不包含 ASockSSL_init 错误。

    出现问题时,您会看到如下所示的内容。

    http:[31/Nov/2006:11:36:21 -0800]
    biotite httpd[27356]: General Error: SSLinitialization error:
    ASockSSL_Init: couldn't open slot Metaslot (-8127)
    imap:[31/Nov/2006:11:36:20 -0800]
    biotite imapd[27354]: General Error: SSLinitialization error:
    ASockSSL_Init: couldn't open slot Metaslot (-8127)
    pop:[31/Nov/2006:11:36:21 -0800]
    biotite popd[27355]: General Error:SSL initialization error:
    ASockSSL_Init: couldn't open slot Metaslot (-8127)
    tcp_smtp_server.log-0J8000L01MGM3Z00:[31/Nov/2006:11:36:22 -0800]
    biotite [27363]: General Error:SSL initialization error:
    ASockSSL_Init: couldn't open slot Metaslot (-8127)
    tcp_smtp_server.log-0J8000L03MGM3Z00:[31/Nov/2006:11:36:22 -0800]
    biotite [27364]: General Error:SSL initialization error:
    ASockSSL_Init: couldn't open slot Metaslot (-8127)

  3. 验证 SSL 端口是否正在进行侦听。
    # netstat -an | grep 995
      *.995                *.*                0      0 49152      0 LISTEN
    # netstat -an | grep 443
      *.443                *.*                0      0 49152      0 LISTEN
    # netstat -an | grep 465
      *.465                *.*                0      0 49152      0 LISTEN

  4. 当应用程序在 Solaris 加密框架上正常运行后,请使用 kstat 命令显示自上次系统引导以来使用 NCP 执行的 RSA 公钥解密的次数。

    RSA 公钥解密次数在 kstat 输出中显示为 rsapublic 值。如果 rsapublic 的值正向递增,则说明 NCP 正常运行。

    # kstat -n ncp0 | grep rsa
    rsprivate                      X
    rsapublic                      X

    在此输出中:

    • rsaprivate -- 针对 RSA 私钥运算提交到设备中的作业总数。

    • rsapublic -- 针对 RSA 公钥运算提交到设备中的作业总数。

    通过使用浏览器连接到 HTTP SSL 端口并进行登录,您会看到计数是如何增加的。例如:

    <Log in to https://host1.red.example.com>
    
    # kstat -n ncp0 | grep rsa
    rsaprivate	35       
    rsapublic 	146
    
    # kstat -n ncp0 | grep rsa
    rsaprivate	38       
    rsapublic 	149


补充读物

可以使用这些资源来了解有关 Solaris 加密框架的更多信息:


除非另行颁发许可,否则此处所有技术手册中的代码(包括文章、常见问题解答和样例)只能在本许可下使用。