5.7. 在 Cisco 路由器上注册证书
简单的证书注册协议(SCEP)由 Cisco 设计,是路由器用来为路由器注册证书的证书颁发机构(如 CA)的一种方式。
通常,路由器安装程序在路由器中输入 CA 的 URL 和质询密码(也称为一次性 PIN),并发出命令来启动注册。然后,路由器通过 SCEP 与 CA 通信来生成、请求和检索证书。路由器也可以使用 SCEP 检查待处理请求的状态。
5.7.1. 启用 SCEP 注册
出于安全考虑,在 CA 中默认禁用 SCEP 注册。要允许注册路由器,必须手动为 CA 启用 SCEP 注册。
- 停止 CA 服务器,以便您可以编辑配置文件。
pki-server stop instance_name
- 打开 CA 的
CS.cfg
文件。vim
/var/lib/pki/instance_name/ca/conf/CS.cfg
- 将
ca.scep.enable
设置为 true。如果没有该参数,则使用 参数添加一行。ca.scep.enable=true
- 重启 CA 服务器。
pki-server start instance_name
5.7.2. 为 SCEP 配置安全设置
通过几个不同的参数,管理员可以设置 SCEP 连接的特定安全要求,如不使用同一证书进行注册身份验证和常规证书注册,或者设置允许的加密算法以防止降级连接强度。这些参数列在 表 5.1 “SCEP 安全性的配置参数” 中。
参数 | 描述 |
---|---|
ca.scep.encryptionAlgorithm | 设置默认或首选加密算法。 |
ca.scep.allowedEncryptionAlgorithms | 设置以逗号分隔的加密算法列表。 |
ca.scep.hashAlgorithm | 设置默认或首选哈希算法。 |
ca.scep.allowedHashAlgorithms | 设置以逗号分隔的哈希算法列表。 |
ca.scep.nickname | 提供用于 SCEP 通信的证书 nickname。除非设置了此参数,否则默认使用 CA 的密钥对和证书。 |
ca.scep.nonceSizeLimit | 设置 SCEP 请求允许的最大非ce 大小(以字节为单位)。默认值为 16 字节。 |
为 SCEP 注册设置连接的安全设置:
- 停止 CA 服务器,以便您可以编辑配置文件。
pki-server stop instance_name
- 打开 CA 的
CS.cfg
文件。vim
/var/lib/pki/instance_name/ca/conf/CS.cfg
- 设置所需的安全参数,如 表 5.1 “SCEP 安全性的配置参数” 中列出的。如果该参数不存在,请将其添加到
CS.cfg
文件中。ca.scep.encryptionAlgorithm=DES3 ca.scep.allowedEncryptionAlgorithms=DES3 ca.scep.hashAlgorithm=SHA1 ca.scep.allowedHashAlgorithms=SHA1,SHA256,SHA512 ca.scep.nickname=Server-Cert ca.scep.nonceSizeLimit=20
- 重启 CA 服务器。
pki-server start instance_name
5.7.3. 为 SCEP 注册配置路由器
注意
不是所有版本的路由器 IOS 都有相关的加密功能。确保固件镜像具有认证机构互操作性功能。证书系统 SCEP 支持已在运行 IOS C2600 软件(C2600-JK9S-M)、版本 12.2 (40), RELEASE SOFTWARE (fc1)的 Cisco 2611 路由器上测试。
在路由器中注册 SCEP 证书前,请确保正确配置了路由器:
- 路由器必须使用 IP 地址、DNS 服务器和路由信息进行配置。
- 路由器的日期/时间必须正确。
- 必须配置路由器的主机名和 dnsname。
有关配置路由器硬件的说明,请参阅路由器文档。
5.7.4. 为路由器生成 SCEP 证书
以下流程详细介绍了如何为路由器生成 SCEP 证书。
- 选择一个随机 PIN。
- 将 PIN 和路由器的 ID 添加到
flatfile.txt
文件中,以便路由器可以直接对 CA 进行身份验证。例如:vim /var/lib/pki/instance_name/ca/conf/flatfile.txt UID:172.16.24.238 PWD:Uojs93wkfd0IS
务必在 PWD 行后插入空行。路由器的 IP 地址可以是 IPv4 地址或 IPv6 地址。第 10.2.4 节 “配置平面文件身份验证” 中描述了使用平面文件身份验证。 - 登录路由器的控制台。在本例中,路由器的名称为 scep :
scep>
- 启用特权命令。
scep> enable
- 进入配置模式。
scep# conf t
- 从 root 开始,为证书链中的每个 CA 导入 CA 证书。例如,以下命令将链中的两个 CA 证书导入到路由器中:
scep(config)# crypto ca trusted-root1 scep(ca-root)# root CEP http://server.example.com:8080/ca/cgi-bin/pkiclient.exe scep(ca-root)# crl optional scep(ca-root)# exit scep(config)# cry ca authenticate 1 scep(config)# crypto ca trusted-root0 scep(ca-root)# root CEP http://server.example.com:8080/ca/cgi-bin/pkiclient.exe scep(ca-root)# crl optional scep(ca-root)# exit scep(config)# cry ca authenticate 0
- 设置 CA 身份,并输入用于访问 SCEP 注册配置文件的 URL。例如,对于 CA:
scep(config)# crypto ca identity CA scep(ca-identity)# enrollment url http://server.example.com:8080/ca/cgi-bin scep(ca-identity)# crl optional
- 获取 CA 的证书。
scep(config)# crypto ca authenticate CA Certificate has the following attributes: Fingerprint: 145E3825 31998BA7 F001EA9A B4001F57 % Do you accept this certificate? [yes/no]: yes
- 生成 RSA 密钥对。
scep(config)# crypto key generate rsa The name for the keys will be: scep.server.example.com Choose the size of the key modulus in the range of 360 to 2048 for your General Purpose Keys. Choosing a key modulus greater than 512 may take a few minutes. How many bits in the modulus [512]: Generating RSA keys ... [OK]
- 最后,在路由器上生成证书。
scep(config)# crypto ca enroll CA % % Start certificate enrollment .. % Create a challenge password. You will need to verbally provide this password to the CA Administrator in order to revoke your certificate. For security reasons your password will not be saved in the configuration. Please make a note of it. Password: secret Re-enter password: secret % The subject name in the certificate will be: scep.server.example.com % Include the router serial number in the subject name? [yes/no]: yes % The serial number in the certificate will be: 57DE391C % Include an IP address in the subject name? [yes/no]: yes % Interface: Ethernet0/0 % Request certificate from CA? [yes/no]: yes % Certificate request sent to Certificate Authority % The certificate request fingerprint will be displayed. % The 'show crypto ca certificate' command will also show the fingerprint. % Fingerprint:D89DB555 E64CC2F7 123725B4 3DBDF263 Jan 12 13:41:17.348: %CRYPTO-6-CERTRET: Certificate received from Certificate
- 关闭配置模式。
scep(config)# exit
- 为确保路由器已正确注册,请列出路由器中存储的所有证书。
scep# show crypto ca certificates Certificate Status: Available Certificate Serial Number: 0C Key Usage: General Purpose Issuer: CN = Certificate Authority O = Sfbay Red hat Domain 20070111d12 Subject Name Contains: Name: scep.server.example.com IP Address: 10.14.1.94 Serial Number: 57DE391C Validity Date: start date: 21:42:40 UTC Jan 12 2007 end date: 21:49:50 UTC Dec 31 2008 Associated Identity: CA CA Certificate Status: Available Certificate Serial Number: 01 Key Usage: Signature Issuer: CN = Certificate Authority O = Sfbay Red hat Domain 20070111d12 Subject: CN = Certificate Authority O = Sfbay Red hat Domain 20070111d12 Validity Date: start date: 21:49:50 UTC Jan 11 2007 end date: 21:49:50 UTC Dec 31 2008 Associated Identity: CA
5.7.5. 使用子 CA
在路由器可以向 CA 进行身份验证前,从 root 开始,必须将 CA 证书链中的每个 CA 证书导入到路由器中。例如,以下命令将链中的两个 CA 证书导入到路由器中:
scep(config)# crypto ca trusted-root1 scep(ca-root)# root CEP http://server.example.com:8080/ca/cgi-bin/pkiclient.exe scep(ca-root)# crl optional scep(ca-root)# exit scep(config)# cry ca authenticate 1 scep(config)# crypto ca trusted-root0 scep(ca-root)# root CEP http://server.example.com:8080/ca/cgi-bin/pkiclient.exe scep(ca-root)# crl optional scep(ca-root)# exit scep(config)# cry ca authenticate 0
如果 CA 证书没有设置 CRL 发行点扩展,请通过将其设置为 可选 来关闭 CRL 要求:
scep(ca-root)# crl optional
之后,设置 CA 身份,如 第 5.7.4 节 “为路由器生成 SCEP 证书” 所述。
5.7.6. 重新注册路由器
在使用新证书重新注册路由器之前,必须删除现有的配置。
- 删除(零化)现有密钥。
scep(config)# crypto key zeroize rsa % Keys to be removed are named scep.server.example.com. Do you really want to remove these keys? [yes/no]: yes
- 删除 CA 身份。
scep(config)# no crypto ca identity CA % Removing an identity will destroy all certificates received from the related Certificate Authority. Are you sure you want to do this? [yes/no]: yes % Be sure to ask the CA administrator to revoke your certificates. No enrollment sessions are currently active.
5.7.7. 启用调试
路由器通过启用 debug 语句在 SCEP 操作过程中提供额外的调试。
scep# debug crypto pki callbacks
Crypto PKI callbacks debugging is onscep# debug crypto pki messages
Crypto PKI Msg debugging is onscep# debug crypto pki transactions
Crypto PKI Trans debugging is onscep#debug crypto verbose
verbose debug output debugging is on
5.7.8. 使用 SCEP 发布 ECC 证书
默认情况下,ECC CA 不支持 SCEP out。但是,可以使用指定的 RSA 证书来处理以下两个区域的每个区域来解决这个问题:
- 加密/解密证书 - 指定具有加密/解密功能的 RSA 证书;(以下示例中的scepRSAcert)
- 签名证书 - 获取在客户端中使用的 RSA 证书以签名目的,而不是自签名;(以下示例中的signingCert 证书)
例如,如果 scepRSAcert 证书是加密/解密证书,并且 signedCert 是签名证书:
sscep enroll -c ca.crt -e scepRSAcert.crt -k local.key -r local.csr -K sign.key -O sign.crt -E 3des -S sha256 -l cert.crt -u 'http://example.example.com:8080/ca/cgi-bin/pkiclient.exe'