远程 apache httpd 服务器的 SSL 握手问题,在本地工作

SSL handshake issue with remote apache httpd server, works locally

我遇到了一个奇怪的问题: 我在 apache 中有 installed/configured ssl certificate/key 和 ca 证书等,现在可以从本地计算机在最新的 chrome/firefox 浏览器上访问它,它们显示证书一切正常(总绿色锁图标), 并使用现代密码套件显示它。 请注意,我是通过服务器名称本身从本地计算机访问它,而不是从本地主机等,而不是通过更改主机文件访问它。它也可以从同一网络中的另一台计算机访问,没有任何问题..

但是当我尝试从不同的远程机器(不在同一网络中)或通过 vpn 等访问它时,我收到 ssl 连接错误。 Firefox 表示 "Peer reports it experienced an internal error. (Error code: ssl_error_internal_error_alert)".

我在远程机器上使用 openssl 命令来模拟客户端:

*openssl s_client -connect xyz.com:443 -state -nbio 2>&1*

显示:

WARNING: can't open config file: /usr/local/ssl/openssl.cnf
Loading 'screen' into random state - done
CONNECTED(00000170)
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
SSL3 alert read:fatal:internal error
SSL_connect:error in SSLv2/v3 read server hello A
7020:error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error:.\ssl\s23_clnt.c:762:
- - - 
no peer certificate available
- - - 
No client certificate CA names sent
- - - 
SSL handshake has read 7 bytes and written 307 bytes
- - - 
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
- - - 

我必须使用 apache httpd 才能使用 https,并转发请求到 tomcat,它仅使用 http,并为此使用了 ajp-proxy。

我尝试删除代理配置,重新启动但仍然没有成功 - 在本地机器上它显示“有效”页面,而在远程机器上,同样的 ssl 连接错误。 apache 日志中没有任何内容也对应于来自远程机器的尝试(即它们不会到达那些日志)。

但奇怪的是,在长时间不工作后,现有配置确实可以在远程机器上工作 30-40 分钟(即一段时间)。然后同样的配置再次折腾..不明白为什么。在此期间,它总是从本地机器保持 accessible/fine..

这里是 ssl-conf:

SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:SSL_RSA_WITH_RC4_128_SHA:HIGH:MEDIUM:!MD5:!RC4
SSLProxyCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:HIGH:MEDIUM:!MD5:!RC4
SSLHonorCipherOrder on 
SSLProtocol all  -SSLv2 -SSLv3
SSLProxyProtocol all -SSLv2  -SSLv3
SSLSessionCache        "shmcb:c:/Apache24/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300
SSLUseStapling On
SSLStaplingCache "shmcb:c:/Apache24/logs/ssl_stapling(150000)"
SSLStaplingStandardCacheTimeout 3600
<VirtualHost *:443>
    DocumentRoot "c:/Apache24/htdocs"
    ServerName www.xyz.com
    ServerAlias xyz.com

    ServerAdmin info@xyz.com
    ErrorLog "c:/Apache24/logs/error.log"
    TransferLog "c:/Apache24/logs/access.log"
    SSLEngine on
    SSLCertificateFile "C:/Apache24/xyz/certs/server.crt"
    SSLCertificateKeyFile "C:/Apache24/xyz/certs/private_key_no_pswd.pem"
    SSLCertificateChainFile "C:/Apache24/xyz/certs/gd_bundle-g2-g1.crt"
    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory "c:/Apache24/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
    CustomLog "c:/Apache24/logs/ssl_request.log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    #ProxyRequests Off
    ProxyPreserveHost On
    SSLProxyEngine on
    SSLProxyVerify none 
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off

    <Proxy *>
        #Order allow,deny
        Allow from all
        Deny from none
        Require all granted

        #Deny from all
        #Allow from 127.0.0.0/255.0.0.0 ::1/128

        # Order deny,allow
        # Allow from localhost
        # Require ip 127.0.0.1
    </Proxy>

    ProxyPass   /  ajp://localhost:8009/
</VirtualHost> 

你可以看到在 virtualHost 配置中尝试了很多东西(被拒绝权限和其他问题),并且尝试了很多东西直到它在本地机器上工作..

我的环境是: Win-XP sp3(我知道它的旧版本)、ApacheLounge httpd- VC-10 v-2.4.x(在端口 443 上)、tomcat-1.6(在 8080 上)

如果我做错了什么,或者您需要任何其他配置才能看到,请告诉我。

谢谢。

这在本地网络中起作用,而不是在外部网络中起作用,这听起来很像保护您网络的防火墙。另一种可能性是相同的主机名在您的本地和远程网络中解析为不同的 IP 地址,因此它会尝试从本地和远程访问不同的主机。还有一件事可能是主机名解析为 IPv4 和 IPv6 地址,但您的服务器仅使用 IPv4。如果您随后在本地网络中仅执行 IPv4 而其他网络可以执行 IPv6,您将看到类似的效果。

为了调试这个问题,我建议在本地客户端和远程客户端上进行数据包捕获并进行比较。还要检查数据包捕获是否来自远程客户端的数据完全到达服务器(或者防火墙是否阻止它)。

编辑:从评论看来,本地和远程客户端看到同一服务器的不同 IP 地址。要调试为什么会出现这种情况,请首先检查双方是否实际使用同一台服务器,因为您经常会看到一方使用 www.example.com 而另一方使用 example.com(没有 www),但它们的 IP 地址不同名字。如果您确定不是这种情况,请检查真实 IP 地址应该是什么,然后更详细地查看名称错误的一方。这个错误的名称可能是由主机文件中的一个条目(来自测试?),缓存的条目(对 DNS take some time to propagate, sometimes a day or longer) or because a split DNS setup is used. Split DNS 的更改在他们的服务器面向 extern 和 intern 并且他们想要实习生的公司中并不少见客户端使用内部 IP 地址,外部客户端使用外部 IP 地址。