簡體   English   中英

即使密碼套件相同,TLS握手也會失敗

[英]Tls handshake fails even though ciphersuites in common

與www.howsmyssl.com/a/check建立安全連接時遇到麻煩。 我正在使用wolfSSL進行連接,但是,握手始終失敗(致命錯誤警報40)。 我試圖嗅探網絡以查看數據包,以查看確切發送了哪些數據以及支持哪些密碼套件,並且根據ssllabs的測試,我發現howsmyssl.com和我的客戶端具有相同的密碼套件。 所以我真的不知道錯誤發生在哪里。 這是客戶端的痕跡:

跟蹤

這是一個鏈接到www.howsmyssl.com的ssllabs analysation。 在這里,您可以看到它們有共同的密碼套件(例如0xc02f),所以我認為連接應該成功,或者我丟失了什么?

編輯:這是wolfssl的調試日志

[0;32mI (6565) openssl_example: OpenSSL demo thread start OK[0m
[0;33mW (6565) openssl_example: Size of long = 4, Size of longlong = 8
[0m
[0;32mI (6565) openssl_example: get target IP address[0m
[0;32mI (6595) openssl_example: OK[0m
[0;32mI (6595) openssl_example: 104.196.190.195[0m
wolfSSL Entering wolfSSL_Init
wolfSSL Entering wolfCrypt_Init
[0;32mI (6595) openssl_example: create SSL context ......[0m
wolfSSL Entering WOLFSSL_CTX_new_ex
wolfSSL Entering wolfSSL_CertManagerNew
wolfSSL Leaving WOLFSSL_CTX_new, return 0
[0;32mI (6615) openssl_example: OK[0m
wolfSSL Entering wolfSSL_CTX_set_verify
wolfSSL Entering wolfSSL_CTX_load_verify_buffer
Getting into SSL_FILETYPE_PEM if
Processing CA PEM file
wolfSSL Entering PemToDer
Adding a CA
wolfSSL Entering GetExplicitVersion
wolfSSL Entering GetSerialNumber
Got Cert Header
wolfSSL Entering GetAlgoId
wolfSSL Entering GetObjectId()
Got Algo ID
Getting Cert Name
Getting Cert Name
Got Subject Name
wolfSSL Entering GetAlgoId
wolfSSL Entering GetObjectId()
Got Key
Parsed Past Key
wolfSSL Entering DecodeCertExtensions
wolfSSL Entering GetObjectId()
wolfSSL Entering DecodeSubjKeyId
wolfSSL Entering GetObjectId()
wolfSSL Entering DecodeAuthKeyId
wolfSSL Entering GetObjectId()
wolfSSL Entering DecodeBasicCaConstraint
wolfSSL Entering GetAlgoId
wolfSSL Entering GetObjectId()
    Parsed new CA
    Freeing Parsed CA
    Freeing der CA
        OK Freeing der CA
wolfSSL Leaving AddCA, return 0
1
   Processed a CA
wolfSSL Entering PemToDer
Couldn't find PEM header
-372
CA Parse failed, no progress in file.
Do not continue search for other certs in file
Processed at least one valid CA. Other stuff OK
[0;32mI (6715) openssl_example: create socket ......[0m
[0;32mI (6725) openssl_example: OK[0m
[0;32mI (6725) openssl_example: bind socket ......[0m
[0;32mI (6735) openssl_example: OK[0m
[0;32mI (6735) openssl_example: socket connect to remote www.howsmyssl.com ......[0m
[0;32mI (6865) openssl_example: OK[0m
[0;32mI (6865) openssl_example: create SSL ......[0m
wolfSSL Entering SSL_new
wolfSSL Leaving SSL_new, return 0
[0;32mI (6865) openssl_example: OK[0m
wolfSSL Entering SSL_set_fd
wolfSSL Entering SSL_set_read_fd
wolfSSL Leaving SSL_set_read_fd, return 1
wolfSSL Entering SSL_set_write_fd
wolfSSL Leaving SSL_set_write_fd, return 1
[0;32mI (6885) openssl_example: SSL connected to www.howsmyssl.com port 443 ......[0m
wolfSSL Entering SSL_connect()
growing output buffer

Shrinking output buffer

connect state: CLIENT_HELLO_SENT
received record layer msg
got ALERT!
Got alert
wolfSSL error occurred, error = 40
wolfSSL error occurred, error = -313
[0;32mI (7065) openssl_example: OK[0m
wolfSSL Entering wolfSSL_get_cipher
wolfSSL Entering SSL_get_current_cipher
wolfSSL Entering SSL_CIPHER_get_name
wolfSSL Entering wolfSSL_get_cipher_name_from_suite
READ USED CIPHERSUITE: NONE
[0;32mI (7085) openssl_example: send https request to www.howsmyssl.com port 443 ......[0m
wolfSSL Entering SSL_write()
handshake not complete, trying to finish
wolfSSL Entering wolfSSL_negotiate
wolfSSL Entering SSL_connect()
ProcessReply retry in error state, not allowed
wolfSSL error occurred, error = -313
wolfSSL Leaving wolfSSL_negotiate, return -1
wolfSSL Leaving SSL_write(), return -1
[0;32mI (7115) openssl_example: failed[0m
wolfSSL Entering SSL_shutdown()
wolfSSL Leaving SSL_shutdown(), return -1
wolfSSL Entering SSL_free
CTX ref count not 0 yet, no free
wolfSSL Leaving SSL_free, return 0
wolfSSL Entering SSL_CTX_free
CTX ref count down to 0, doing full free
wolfSSL Entering wolfSSL_CertManagerFree
wolfSSL Leaving SSL_CTX_free, return 0
I (14055) wifi: pm start, type:0

我嘗試連接到www.google.com的更新 ,此操作成功。 我的代碼未做任何更改,因此我認為這將是服務器問題。 但是,當我使用mbedtls連接到www.howsmyssl.com時,請求也成功,並且在通過嗅探網絡比較數據包之后,看不到任何主要差異。

僅與客戶端共享客戶端您好在這里無濟於事。 您將需要收集一些與SSL相關的日志。 我不是wolfssl專家,但是當您使用--enable-debug進行編譯時,它看起來像暴露了其他日志。 我指的是: WolfSL-SSL Alert致命錯誤

密碼套件不是唯一會出錯的東西。 如果服務器在客戶端Hello中以某種格式期望某個TLS擴展 ,並且即使在這種情況下也未被接受,則服務器可以終止握手。

請參閱此線程以供參考: clientHello之后的SSL handshake_failure

沒有調試日志,就像在黑暗中拍攝一樣。

更新:

因此,這些是日志中的錯誤:

wolfSSL error occurred, error = 40
wolfSSL error occurred, error = -313

313表示服務器不喜歡客戶端發送的以下消息之一:

  • 密碼套件
  • TLS擴展

由於您已經指定了支持的曲線,因此您可以嘗試啟用靜態密鑰密碼套件 這些似乎在WolfSSL中默認為禁用。 WolfSSL-支持的密碼套件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM