HTTPD + OpenSSL - 连接到端口 443 需要很长时间,然后出现 ssl_handshake_failure

HTTPD + OpenSSL - 连接到端口 443 需要很长时间,然后出现 ssl_handshake_failure

我知道 ssl_handshake_failure 是一个通用错误,但这是我的最后手段,因为我已经调查这个问题三个星期了。

我正在 AIX 服务器上部署 Apache HTTPD 服务器。AIX 没有标准存储库,因此我从 perzl.org/aix/ 的 RPM 包安装了它

我费了好大劲才解决所有依赖关系,但最终还是成功了。我希望 RPM 不会让我在没有所有适当依赖关系的情况下这样做。

当我仅通过端口 80 使用 HTTP 时,apache 服务器运行良好。当我尝试通过端口 443 连接到它时出现问题。

我使用以下命令对其进行测试:

openssl s_client -state -connect 127.0.0.1:443

一旦运行此命令,我就会得到:

CONNECTED(00000003)
SSL_connect:before/connect initialization
SSL_connect:SSLv2/v3 write client hello A

然后 OpenSSL 等待大约两分钟,然后抛出以下错误:

804401144:error:140790E5:SSL routines:ssl23_write:ssl handshake failure:s23_lib.c:177:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 305 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : 0000
    Session-ID:
    Session-ID-ctx:
    Master-Key:
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1505947800
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)
---

这很奇怪,似乎 apache不发回任何数据,然后经过一段时间超时后,OpenSSL 客户端“厌倦”等待,然后抛出错误。

我试图使我的配置尽可能简单,因为现在我只想完成一次握手。

这是我的 httpd-ssl.conf

LoadModule ssl_module /opt/freeware/lib/httpd/modules/mod_ssl.so

Listen 443

SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4
SSLProtocol all -SSLv3


<VirtualHost *:443>

DocumentRoot "/usr/local/Tomcat/tomcat1/webapps/ROOT"
ServerName <server_name>:443
ServerAdmin root@localhost
ErrorLog "logs/httpd/ssl_error_log"
LogLevel trace8
TransferLog "logs/httpd/ssl_access_log"
LogLevel trace8

SSLEngine on

SSLCertificateFile "cert.crt"
SSLCertificateKeyFile "cert.key"


<FilesMatch "\.(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/var/www/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

BrowserMatch "MSIE [2-5]" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

CustomLog "/var/log/httpd/ssl_request_log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

我把所有的日志都放在 trace8 级别,但这对我没有帮助,当我尝试完成 SSL 握手时,这是我从ssl_错误日志

[ssl:info] [client 127.0.0.1:36193] AH01964: Connection to child 66 established (server <server_name>:443)
[ssl:trace2] ssl_engine_rand.c(125): Seeding PRNG with 136 bytes of entropy
[ssl:trace3] ssl_engine_kernel.c(1988): [client 127.0.0.1:36193] OpenSSL: Handshake: start
[ssl:trace3] ssl_engine_kernel.c(1996): [client 127.0.0.1:36193] OpenSSL: Loop: before/accept initialization
[ssl:info] [client 194.10.155.114:52781] AH01964: Connection to child 65 established (server <server_name>:443)
[ssl:trace2] ssl_engine_rand.c(125): Seeding PRNG with 136 bytes of entropy
[ssl:trace3] ssl_engine_kernel.c(1988): [client 194.10.155.114:52781] OpenSSL: Handshake: start
[ssl:trace3] ssl_engine_kernel.c(1996): [client 194.10.155.114:52781] OpenSSL: Loop: before/accept initialization

OpenSSL 版本:

OpenSSL 1.0.2j-fips  26 Sep 2016

Apache HTTPD 版本:

Server version: Apache/2.4.25 (Unix)

大家知道我可能遗漏了什么吗?为什么握手错误需要相当长的时间才会出现,类似于超时错误?

我担心这可能是我错过的某些虚拟内容,或者是一些复杂的依赖关系问题,因为我没有从任何存储库安装它。

有什么猜测吗?

答案1

使用真实的服务器名称而不是“ ServerName <server_name>:443”。 https://httpd.apache.org/docs/current/en/mod/core.html#servername

“如果未指定 ServerName,则服务器将尝试通过首先向操作系统询问系统主机名来推断客户端可见的主机名,如果失败,则对系统上存在的 IP 地址执行反向查找。”

相关内容