【发布时间】:2015-04-03 17:29:29
【问题描述】:
我以为我明白了,但它不起作用!
我读到了http://binblog.info/2010/02/02/lengthy-chains/,这是我找到的最简洁的解释。
背景: Comodo 便宜的 PositiveSSL 服务器证书带有一个根证书和两个中间 CA 证书(我用 myserver.com 替换了我的 FQDN):
$ unzip ../myserver_com.commodo.certificate.zip
Archive: ../myserver_com.commodo.certificate.zip
extracting: AddTrustExternalCARoot.crt
extracting: COMODORSAAddTrustCA.crt
extracting: COMODORSADomainValidationSecureServerCA.crt
extracting: myserver_com.crt
请注意,字母顺序类似于从根 CA 到服务器证书的倒置证书链。根 CA 不是 Comodo,但这不是重点。
考虑以下输出:
openssl x509 -noout -subject -issuer -in myserver_com.crt
subject= /OU=Domain Control Validated/OU=PositiveSSL/CN=myserver.com
issuer= /C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA
openssl x509 -noout -subject -issuer -in COMODORSADomainValidationSecureServerCA.crt
subject= /C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA
issuer= /C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Certification Authority
openssl x509 -noout -subject -issuer -in COMODORSAAddTrustCA.crt
subject= /C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Certification Authority
issuer= /C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
openssl x509 -noout -subject -issuer -in AddTrustExternalCARoot.crt
subject= /C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
issuer= /C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
前一个证书的颁发者是后者的主体 - 直到来自 AddTrust AB 的根 CA 证书是自签名的。链条已完成。
验证单个证书给出:
$ openssl verify *.crt
AddTrustExternalCARoot.crt: OK
COMODORSAAddTrustCA.crt: OK
COMODORSADomainValidationSecureServerCA.crt: C = GB, ST = Greater Manchester, L = Salford, O = COMODO CA Limited, CN = COMODO RSA Domain Validation Secure Server CA
error 20 at 0 depth lookup:unable to get local issuer certificate
myserver_com.crt: OU = Domain Control Validated, OU = PositiveSSL, CN = myserver.com
error 20 at 0 depth lookup:unable to get local issuer certificate
前两个证书已经安装在服务器上,剩下两个证书要连接,但我还是把它们都链接了。
来自 RFC5246 https://www.rfc-editor.org/rfc/rfc5246#section-7.4.2
certificate_list This is a sequence (chain) of certificates. The sender's certificate MUST come first in the list. Each following certificate MUST directly certify the one preceding it. Because certificate validation requires that root keys be distributed independently, the self-signed certificate that specifies the root certificate authority MAY be omitted from the chain, under the assumption that the remote end must already possess it in order to validate it in any case.
当我以正确的方式链接证书时,证书被识别为 TLS 会话的服务器证书,但未经验证。
$ cat myserver_com.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt > chained.crt
$ openssl verify chained.crt
chained.crt: OU = Domain Control Validated, OU = PositiveSSL, CN = das.email
error 20 at 0 depth lookup:unable to get local issuer certificate
当连接到服务器时
$ openssl s_client -crlf -connect myserver:465
证书被接受并且链被识别,但根证书未被识别为受信任,尽管它存在于 /etc/ssl/mozilla/ 中的受信任证书中。
我错过了什么?我可以简单地忽略命令行 openssl 工具中的错误吗?
【问题讨论】:
-
这个问题似乎离题了,因为它与编程或开发无关。请参阅帮助中心的What topics can I ask about here。也许Super User 或Information Security Stack Exchange 会是一个更好的提问地点。
-
@jww 感谢您指出这一点——我想知道为什么没有人看过它——所以它确实似乎离题了。纽比,你看。我会考虑你的提示。老实说,我没有查看主题政策 - 我只是碰巧在这里找到了我所有未受过教育的业余服务器管理员问题的最佳答案。
标签: ssl openssl ssl-certificate x509