首页 > 解决方案 > Nginx-1.19.6 + Openssl 1.1.1i - 无法进行 SSL 握手

问题描述

我正在尝试使用带有 sslv3 和密码 RC4-SHA:RC4-MD5 支持的 Nginx 运行服务器(我需要这些密码)。我能够在 Ubuntu 16.04 上使用 Openssl 1.0.2u 源 + 最后一个 nginx 版本源 (nginx-1.19.6) 做到这一点。我使用以下命令构建了 Nginx:

./configure --with-http_ssl_module --with-openssl=/path/to/openssl-1.0.2u --with-openssl-opt=enable-ssl3 --with-openssl-opt=enable-ssl3-method --with-openssl-opt=enable-weak-ssl-ciphers

我使用的 Nginx 配置是:

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    ssl_protocols SSLv3;
    ssl_ciphers RC4-SHA:RC4-MD5:@SECLEVEL=0;
    ssl_certificate /path/to/server-chain.crt;
    ssl_certificate_key /path/to/server.key;
    server_name server.name.net;
    underscores_in_headers on;
    proxy_pass_request_headers on;
    location / {    
        proxy_set_header X-Forwarded-Host \$host:\$server_port;
        proxy_set_header X-Forwarded-Server \$host;
        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:9000;
    }
}

设置 nginx 配置文件后,一切正常。我能够使用以下命令从 Ubuntu 14.04 机器获取 ssl 证书:

openssl s_client -connect MyIP:443 -ssl3 -cipher RC4-SHA:RC4-MD5.

我尝试使用具有相同配置选项的 Openssl 1.1.1i 源构建 Nginx,但是在设置 nginx conf 文件后,当我尝试运行openssl s_client -connect...命令时,出现此错误:

CONNECTED(00000003)
140420793624224:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number:s3_pkt.c:339:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 5 bytes and written 7 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
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1612540521
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
---

在 Nginx error.log 文件中,我得到了这个:

SSL_do_handshake() failed (SSL: error:141FC044:SSL routines:tls_setup_handshake:internal error) while SSL handshaking, client: 192.168.1.10, server: 0.0.0.0:443

openssl 1.1.1 有什么变化吗?我是否缺少启用 SSLv3 + RC4-SHA:RC4-MD5 的任何配置选项?感谢您的任何提示!

标签: nginxsslopenssl

解决方案


最后我能够解决这个问题!

我下载了最后一个 openssl 源(1.1.1i)和最后一个 nginx 源(1.19.6)。我使用以下命令编译并安装了 openssl:

./config enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers
make
sudo make install

我编辑了 openssl.cnf 文件(/usr/local/ssl/openssl.cnf)添加

openssl_conf = default_conf

在文件的开头并添加

[default_conf]
ssl_conf = ssl_sect

[ssl_sect]
system_default = system_default_sect

[system_default_sect]
CipherString = ALL:@SECLEVEL=0

在文件的底部。这启用了旧密码(我需要 RC4-SHA 和 RC4-MD5)。然后我使用以下命令编译并安装了 nginx:

./configure --with-http_ssl_module --with-ld-opt="-L/usr/local"
make
sudo make install

在为 ssl 证书配置 nginx 后,我可以使用openssl s_client...命令获取它们!


推荐阅读