使用 SSL 密码连接 nginx websocket

标签 c ssl encryption nginx websocket

我使用以下配置部署了一个 nginx 网络服务

server {
    listen 443;
    server_name localhost;
    root html;
    index index.html index.htm;
    ssl on;
    ssl_certificate /etc/nginx/ssl/current.crt;
    ssl_certificate_key /etc/nginx/ssl/current.key;
    ssl_session_timeout 5m;
    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
    ssl_prefer_server_ciphers on;

    location / {
            proxy_pass http://172.16.9.245:33400;
    }
    location /csconf/ {
            proxy_pass http://172.16.9.245:33200;
    }
    location /websockets/ {
            proxy_pass http://172.16.9.245:33143;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
    }
}

我的客户尝试使用 C 代码连接到这个 websocket

.....
const SSL_METHOD *meth = SSLv3_method();
SslCtx = SSL_CTX_new(meth);
SSL_CTX_set_options(SslCtx, SSL_OP_NO_COMPRESSION);
SSL_CTX_set_cipher_list(SslCtx, "RC4-SHA:DEC-CBC3-SHA:DES-CBC-SHA");
.....
int ret = SSL_connect(obj->ssl);

它抛出“error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure:s23_clnt.c:741:”

为什么会出现握手错误?请帮我解释一下这个问题。

谢谢

最佳答案

我不确定这是否是原因,但它修复了我遇到的握手错误:

改变

proxy_set_header 连接“升级”;

到首都升级

proxy_set_header 连接“升级”;

关于使用 SSL 密码连接 nginx websocket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30770701/

相关文章:

c - 维护指向地址的指针链

rest - SunCertPathBuilderException : unable to find valid certification path to requested target in CN1 app

ssl - 没有为 "ssl_certificate"指令定义 "listen ... ssl"

encryption - Windows 10 和 Linux 的 TPM 所有者密码和锁定密码

encryption - 量子计算和加密破解

Laravel 5.8 - 保存加密的用户电子邮件

c - 为 Python 程序员优化编译器思维

c - 在 Windows : "main already defined" 上与 pgi 一起编译 C/Fortran 代码时出现问题

C命令行参数检查

SSL证书认证