windows - 用于 64 位 Windows 和 "no shared cipher"的 OpenSSL

标签 windows ssl openssl x509 pkix

我刚刚为 64 位 Windows 编译并安装了 OpenSSL。我已经使用以下命令创建了一个自签名证书和一个私钥:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 10000 -nodes

我现在正在测试 "Simple TLS Server" example在带有 Firefox 的 OpenSSL Wiki 上找到,并进行了一些修改以支持 Winsock,但我一直收到错误

11216:error:1417A0C1:SSL routines:tls_post_process_client_hello:no shared cipher:ssl\statem\statem_srvr.c:1422:

(第一个数字总是变化的)在 SSL_accept() 函数执行期间。当使用 Wireshark 连接到某些 HTTPS 服务器时,我检查了 Firefox(v 43.0.1)在其 TLS v1.2 Client Hello 中发送的(11)个密码列表(因为在本地主机上捕获很困难)并将其与支持的密码进行比较通过我安装的 OpenSSL(使用 openssl.exe ciphers -s -tls1_2 -V 找到)。结果是普通密码,所以我错过了什么?!

包含 statem_srvr.c 的第 1422 行的 block 如下,从 1420 开始:

if (cipher == NULL) {
    SSLerr(SSL_F_TLS_POST_PROCESS_CLIENT_HELLO,
           SSL_R_NO_SHARED_CIPHER);
    goto f_err;
}

对原代码的修改在while循环之前和header中:

#pragma comment(lib,"Ws2_32.lib")
#include <stdio.h>
#include <winerror.h>
#include <WinSock2.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/applink.c>

int sock;
SSL_CTX *ctx;

WSADATA WsaDat;
if (WSAStartup(MAKEWORD(2, 2), &WsaDat) != 0) perror("Winsock fatal startup error");
init_openssl();
ctx = create_context();
configure_context(ctx);

sock = create_socket(4433);

编辑:这是当我尝试使用带有 TLSv1.2 的 s_client 连接到服务器时发生的情况:

CONNECTED(000000F0)
23368:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:ssl\record\rec_layer_s3.c:1362:SSL alert number 40
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 176 bytes
Verification: OK
---
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:
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1473536238
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
    Extended master secret: no
---

最佳答案

事实证明,查找证书和私钥时出现问题。问题解决了。

关于windows - 用于 64 位 Windows 和 "no shared cipher"的 OpenSSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39428438/

相关文章:

java - 了解 Java 调试 SSL 消息

openssl - 如何使用 ECDSA 以编程方式创建自签名数字证书

c - 如何将 OpenSSL 与 emscripten 链接?

php - 无法使用 SSL 连接到 test.salesforce.com

linux - 为多个 GPU 编写 CUDA 程序

java - Runtime.getRuntime().availableProcessors()

windows - 在 Unix/Linux 平台上运行的 Perl 脚本是否可以创建 Windows 快捷方式?

c++ - 在 MessageBox c++ 中显示一个变量

amazon-web-services - 是否可以在没有负载均衡器的情况下使用带 SSL (HTTPS) 的 Amazon Elastic Beanstalk?

ssl - centos7 wget over ssl : Unable to establish SSL connection