【问题标题】:Incorrect certificate installation证书安装不正确
【发布时间】:2015-11-15 23:46:38
【问题描述】:

我们正在使用具有以下特点的 CentOS:

操作系统 CentOS Linux 5.5 Webmin 版本 1.510 i686 上的内核和 CPU Linux 2.6.18-194.3.1.el5xen 处理器信息 Intel(R) Xeon(TM) CPU 3.20GHz, 1 cores

在这个操作系统上,我们在路径中为多个域运行了 tomcat 7:

Using CATALINA_BASE:   /usr/local/software/tomcat7
Using CATALINA_HOME:   /usr/local/software/tomcat7

我们有一些应用程序正在运行。

密钥生成为 PKCS#12 文件并使用 keytool 转换为 Java KeyStore:

keytool -importkeystore -deststorepass keystorepass -destkeypass addkeypass -destkeystore myKeyStore.jks -srckeystore serverabcdj0.p12 -srcstoretype PKCS12 -srcstorepass PKCS12pass -alias latiendamiga.com 

CSR 生成:

keytool -certreq -alias latiendamiga.com -file csraj0s.txt -keystore myKeyStore.jks

然后我安装了从 CA GoDaddy 获得的 SSL 证书。由于误解而以错误的方式进行了此安装,我以 root 身份安装了错误的证书,然后我删除了证书(root、中间和主要),然后我安装了正确的证书,当我列出我的密钥库时,我可以见:

    ***CMD***:-list -keystore myKeyStore.jks

    ***ASW***:Keystore type: JKS
    Keystore provider: SUN

    Your keystore contains 3 entries

    root, Aug 21, 2015, trustedCertEntry,
    Certificate fingerprint (SHA1): XXXXXXX
    tomcat, Aug 21, 2015, trustedCertEntry,
    Certificate fingerprint (SHA1): XXXXXXX
    intermed, Aug 21, 2015, trustedCertEntry,
    Certificate fingerprint (SHA1): XXXXXXX

但是当我尝试检查证书是否正常工作时,我遇到了我不理解的错误。

我有如下测试证书安装(命令 CMD / 回答 ASW):

    ***CMD***: echo "" | openssl s_client -state -showcerts -connect www.latiendamiga.com:443

    ***ASW[/u][/b]: CONNECTED(00000003)
    SSL_connect:before/connect initialization
    SSL_connect:SSLv2/v3 write client hello A
    4721:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:188:

    ***CMD***: echo "" | openssl s_client -nbio_test -showcerts -connect www.latiendamiga.com:443

    ***ASW[/u][/b]: CONNECTED(00000003)
    write W BLOCK
    write W BLOCK
    write W BLOCK
    write W BLOCK
    write W BLOCK
    write W BLOCK
    4728:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:188:

    ***CMD***: echo "" | openssl s_client -msg -showcerts -connect www.latiendamiga.com:443

    ***ASW***: CONNECTED(00000003)
    >>> SSL 2.0 [length 0077], CLIENT-HELLO
        01 03 01 00 4e 00 00 00 20 00 00 39 00 00 38 00
        00 35 00 00 16 00 00 13 00 00 0a 07 00 c0 00 00
        33 00 00 32 00 00 2f 03 00 80 00 00 05 00 00 04
        01 00 80 00 00 15 00 00 12 00 00 09 06 00 40 00
        00 14 00 00 11 00 00 08 00 00 06 04 00 80 00 00
        03 02 00 80 00 00 ff 93 fc 24 f4 45 d0 ec bf 2d
        3d 4d ae 59 e8 77 1d 6c 04 5f 59 0d 5b 19 a2 c3
        78 74 06 fc ab 4a 72
    4732:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:188:

    ***CMD***: echo "" | openssl s_client -debug -showcerts -connect www.latiendamiga.com:443

    ***ASW***: CONNECTED(00000003)
    write to 0x90372f8 [0x90b5528] (121 bytes => 121 (0x79))
    0000 - 80 77 01 03 01 00 4e 00-00 00 20 00 00 39 00 00   .w....N... ..9..
    0010 - 38 00 00 35 00 00 16 00-00 13 00 00 0a 07 00 c0   8..5............
    0020 - 00 00 33 00 00 32 00 00-2f 03 00 80 00 00 05 00   ..3..2../.......
    0030 - 00 04 01 00 80 00 00 15-00 00 12 00 00 09 06 00   ................
    0040 - 40 00 00 14 00 00 11 00-00 08 00 00 06 04 00 80   @...............
    0050 - 00 00 03 02 00 80 00 00-ff 97 5c 69 fd 61 9d 2e   ..........\i.a..
    0060 - e5 58 60 d5 83 9b 1a 70-ce 3c b2 0e b3 3b 03 31   .X`....p.<...;.1
    0070 - 0d 02 16 09 1f 76 eb d2-7f                        .....v...
    read from 0x90372f8 [0x90baa88] (7 bytes => 0 (0x0))
    4737:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:188:

    ***CMD***: echo "" | openssl s_client -showcerts -showcerts -connect www.latiendamiga.com:443

    ***ASW***: CONNECTED(00000003)
    4742:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:188:

    ***CMD***: echo "" | openssl s_client -key myKeyStore.jks -state -showcerts -connect www.latiendamiga.com:443

    ***ASW***: unable to load client certificate private key file
    4762:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:647:Expecting: ANY PRIVATE KEY
    -bash: echo: write error: Broken pipe

    ***CMD***: echo "" | openssl s_client -verify depth -state -showcerts -connect www.latiendamiga.com:443

    ***ASW[/u][/b]: verify depth is 0
    CONNECTED(00000003)
    SSL_connect:before/connect initialization
    SSL_connect:SSLv2/v3 write client hello A
    4770:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:188:

    ***CMD***: echo "" | openssl s_client -nbio -state -showcerts -connect www.latiendamiga.com:443

    ***ASW***: CONNECTED(00000003)
    turning on non blocking io
    SSL_connect:before/connect initialization
    SSL_connect:SSLv2/v3 write client hello A
    SSL_connect:error in SSLv2/v3 read server hello A
    write R BLOCK
    4774:error:140780E5:SSL routines:SSL23_READ:ssl handshake failure:s23_lib.c:142:

    ***CMD***: openssl s_client -ssl3 -connect www.latiendamiga.com:443 -prexit

    ***ASW***: CONNECTED(00000003)
    4810:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:536:
    ---
    no peer certificate available
    ---
    No client certificate CA names sent
    ---
    SSL handshake has read 0 bytes and written 0 bytes
    ---
    New, (NONE), Cipher is (NONE)
    Secure Renegotiation IS NOT supported
    Compression: NONE
    Expansion: NONE
    SSL-Session:
        Protocol  : SSLv3
        Cipher    : 0000
        Session-ID:
        Session-ID-ctx:
        Master-Key:
        Key-Arg   : None
        Krb5 Principal: None
        Start Time: 1440220364
        Timeout   : 7200 (sec)
        Verify return code: 0 (ok)
    ---

环境配置如下:

/usr/local/software/tomcat7/conf/server.xml

    <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />

    <Connector SSLEnabled="true" acceptCount="100" clientAuth="false" disableUploadTimeout="true" enableLookups="false" maxThreads="25" port="443" keystoreFile="/etc/webmin/myKeyStore.jks" keystorePass="mypass" protocol="org.apache.coyote.http11.Http11NioProtocol" scheme="https" secure="true" sslProtocol="TLS" />

    <Connector port="8009" protocol="AJP/1.3" redirectPort="443" />

/usr/local/software/tomcat7/conf/web.xml

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Automatic SSL Forward</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>
                CONFIDENTIAL
            </transport-guarantee>
        </user-data-constraint>
    </security-constraint>

我需要一些帮助来了解哪里出了问题以及我必须做些什么来解决它。

请问有人可以告诉我是否有任何文档可以让我搜索解决方案或如何检查问题所在?

提前致谢。

【问题讨论】:

  • 密钥库包含 3 个trustedCertEntries,但没有私钥。这行不通。在您的问题中添加您如何为 GoDaddy 创建密钥和 CSR。
  • 感谢您的快速回答,有请求的数据
  • 密钥生成:keytool -importkeystore -deststorepass keystorepass -destkeypass addkeypass -destkeystore myKeyStore.jks -srckeystore serverabcdj0.p12 -srcstoretype PKCS12 -srcstorepass PKCS12pass -alias latiendamiga.com CSR 生成:keytool -certreq -alias latiendamiga .com -file csraj0s.txt -keystore myKeyStore.jks
  • 我看到了您的编辑尝试。在重新开始之前删除 myKeyStore.jks 会更好。但这不是问题。从密钥库中删除别名为“tomcat”的 SSL 证书仍然会更好,因此它在密钥库中不是 2x。然后使用“keytool -v -list ...”检查密钥条目是否包含正确的证书。
  • 它不起作用,可能是因为证书不正确,我已经向 CA 发送了一封邮件,以澄清我必须准确使用哪些证书。我已删除所有证书,当我再次尝试添加时,它显示别名已存在。你知道如何确定最后一点吗?

标签: openssl certificate tomcat7 centos5


【解决方案1】:

问题是属于 SSL 证书的私钥不在密钥库中(不再存在)。它只包含三个受信任的证书条目,但没有密钥对条目。

因此,您必须重复从 PKCS#12 到 Java KeyStore (keytool -importkeystore ...) 的转换步骤。在这一步之后,您在别名“latiendamiga.com”下再次拥有myKeyStore.jks 中的密钥。您应该使用keytool -list ... 验证这一点。

然后再次从 GoDaddy 导入证书。作为可信证书的第一个根 CA 和中间 CA:

keytool -importcert -alias root -file <root ca file>
keytool -importcert -alias intermed -file <intermediate ca file>

然后是 SSL 证书:

keytool -importcert -alias latiendamiga.com -trustcacerts -file <ssl cert file>

【讨论】:

  • 我已删除所有证书和私钥并再次添加它,但它不起作用。执行列表 -v 并显示三个证书和私钥但如果我尝试latiendamiga.com 应用程序不显示.我已经执行了 echo "" | openssl s_client -nbio -state -showcerts -connect www.latiendamiga.com:443 CONNECTED(00000003) 打开非阻塞 io SSL_connect:before/connect 初始化 SSL_connect:SSLv2/v3 write client hello A SSL_connect:error in SSLv2/v3 read server你好A写R块
  • 好的,显然还有第二个问题。您是否在 CentOS 5.5 机器(真的很旧)上使用 openssl 0.98 进行测试? openssl 和 tomcat 之间可能存在兼容性问题(例如unix.stackexchange.com/questions/164102/…)。特别是因为您设置了sslProtocol="TLS"。您是否尝试连接浏览器、KeyStore Explorer 或最近的 openssl 版本?
  • 我不确定您的问题“您尝试连接浏览器、KeyStore Explorer 还是最近的 openssl 版本?”我正在尝试更新我的 CentOS 版本,但此时“连接浏览器,KeyStore Explorer”是什么意思,我使用的是 Mozilla Firefox 39.0、Internet Explorer 11.0 和 Google Chrome 44.0.2403.157 m。再次发送。
  • @fern 您似乎总是使用 openssl 来检查 SSL 是否正常工作。当您打开 www.latiendamiga.com 时,您是否在 Firefox 或 IE 中也遇​​到错误?
  • @Oikron 如果我们尝试使用 https://... 打开页面,它会在 IE、firefox 或 chrome 中失败。我们正在将 CentOS 从 5.5 升级到 6.x 以获得 TSLv2 功能。我希望它修复,我们必须尽快启动应用程序.. 为您的 cmets 发送。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-30
  • 1970-01-01
  • 2019-03-19
  • 1970-01-01
  • 2015-08-20
相关资源
最近更新 更多