我剛編譯並安裝了64位Windows的OpenSSL。我創建了一個自簽名的證書,可以在命令私鑰:適用於64位Windows和「無共享密碼」的OpenSSL
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 10000 -nodes
我現在測試"Simple TLS Server" example在OpenSSL的維基與Firefox和一對夫婦的修改,以支持的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)發送的(11)密碼在其TLS v1.2 Client Hello中的列表,並將其與支持的通過我安裝的OpenSSL(使用openssl.exe ciphers -s -tls1_2 -V
找到)。結果是有是常見的密碼,所以我錯過了什麼?!
含有statem_srvr.c的線1422的塊是以下,從1420:
if (cipher == NULL) {
SSLerr(SSL_F_TLS_POST_PROCESS_CLIENT_HELLO,
SSL_R_NO_SHARED_CIPHER);
goto f_err;
}
到原始代碼的修改都在while循環前和在標頭:
#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);
編輯:這是當我嘗試連接到使用的s_client.First與TLSv1.2工作的服務器會發生什麼:
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
---
你能夠使用openssl本身連接到本地服務器嗎?它連接什麼密碼? 'openssl s_client -connect localhost:4433 -tls1_2' –
不,我得到同樣的錯誤。我將發佈客戶端程序的輸出。 –
@JasonHoetger - 他在Windows機器上。他可能需要使用TLS 1.0而不是1.2(SChannel在Windows的可能版本中缺少TLS 1.2)。 @Æðelstan - 嘗試'openssl s_client -connect localhost:4433 -tls1 -servername localhost'。 '-servername'登記SNI,這是一個TLS 1.0及以上的功能。 4096位密鑰也可能是一個問題。許多版本的Windows只能處理2048位密鑰。 – jww