websocketpp icon indicating copy to clipboard operation
websocketpp copied to clipboard

handle_transport_init received error: TLS handshake failed,WebSocket Connection [::1]:6643 - "" - 0 websocketpp.transport.asio.socket:5 TLS handshake timed out

Open naive-Little-Bird opened this issue 6 years ago • 3 comments

I use the example of the tls_server , but it not work. I debug the program,find the verify_subject_alternative_name function and verify_common_name function return false, how can l fix it? Can anyone help me, Thank you!

naive-Little-Bird avatar Oct 31 '19 03:10 naive-Little-Bird

Hei, I have the same error !!

` [2021-03-02 15:28:29] [connect] Successful connection

[2021-03-02 15:28:29] [error] handle_transport_init received error: TLS handshake failed

[2021-03-02 15:28:29] [info] asio async_shutdown error: asio.ssl:336462231 (shutdown while in init) set_reconnecting_listener `

ghost avatar Mar 02 '21 14:03 ghost

In the end, I didn't solve it!I use nginx to do forwarding....

 

------------------ 原始邮件 ------------------ 发件人: "zaphoyd/websocketpp" <[email protected]>; 发送时间: 2021年3月2日(星期二) 晚上10:30 收件人: "zaphoyd/websocketpp"<[email protected]>; 抄送: "294450950"<[email protected]>;"Author"<[email protected]>; 主题: Re: [zaphoyd/websocketpp] handle_transport_init received error: TLS handshake failed,WebSocket Connection [::1]:6643 - "" - 0 websocketpp.transport.asio.socket:5 TLS handshake timed out (#848)

Hei, I have the same error !!

[2021-03-02 15:28:29] [connect] Successful connection [2021-03-02 15:28:29] [error] handle_transport_init received error: TLS handshake failed [2021-03-02 15:28:29] [info] asio async_shutdown error: asio.ssl:336462231 (shutdown while in init) set_reconnecting_listener

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

naive-Little-Bird avatar Mar 03 '21 01:03 naive-Little-Bird

Instead of using the verify_common_name and verify_subject_alternative_name functions in the example, this worked for me:

websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context> on_tls_init(const char * hostname, websocketpp::connection_hdl) {
    auto ctx = websocketpp::lib::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::sslv23);

    try {
        ctx->set_options(boost::asio::ssl::context::default_workarounds |
                         boost::asio::ssl::context::no_tlsv1 |
                         boost::asio::ssl::context::no_sslv2 |
                         boost::asio::ssl::context::no_sslv3 |
                         boost::asio::ssl::context::single_dh_use);


        ctx->set_verify_mode(boost::asio::ssl::verify_peer);
        ctx->set_default_verify_paths();
        ctx->set_verify_callback(boost::asio::ssl::host_name_verification(std::string(hostname)));
    } catch (std::exception& e) {
        // handle exception
    }
    return ctx;
}

jwpleow avatar Apr 23 '25 11:04 jwpleow