我使用cpprestsdk「卡薩布蘭卡」主分支HTTPS URL,它的工作在Windows和OSX但是當我在linux上運行它,我收到「錯誤是SSL握手」如何解決cpprestsdk中的「ssl握手錯誤」?
C++ exception with description "Error in SSL handshake" thrown in the test body.
我試圖打開這個它使用Firefox的網址。
當我與HTTP URL中使用它一切正常 我檢查在客戶端,我發現代碼此消息在一個文件名爲「http_client_asio.cpp」
void write_request()
{
// Only perform handshake if a TLS connection and not being reused.
if (m_connection->is_ssl() && !m_connection->is_reused())
{
const auto weakCtx = std::weak_ptr<asio_context>(shared_from_this());
m_connection->async_handshake(boost::asio::ssl::stream_base::client,
m_http_client->client_config(),
m_http_client->base_uri().host(),
boost::bind(&asio_context::handle_handshake, shared_from_this(), boost::asio::placeholders::error),
// Use a weak_ptr since the verify_callback is stored until the connection is destroyed.
// This avoids creating a circular reference since we pool connection objects.
[weakCtx](bool preverified, boost::asio::ssl::verify_context &verify_context)
{
auto this_request = weakCtx.lock();
if(this_request)
{
return this_request->handle_cert_verification(preverified, verify_context);
}
return false;
});
}
else
{
m_connection->async_write(m_body_buf, boost::bind(&asio_context::handle_write_headers, shared_from_this(), boost::asio::placeholders::error));
}
}
void handle_handshake(const boost::system::error_code& ec)
{
if (!ec)
{
m_connection->async_write(m_body_buf, boost::bind(&asio_context::handle_write_headers, shared_from_this(), boost::asio::placeholders::error));
}
else
{
report_error("Error in SSL handshake", ec, httpclient_errorcode_context::handshake);
}
}
我craeted HTTP客戶端這樣的
http_client client(U("https://www.bing.com/"));
我該如何解決這個錯誤?
[相關](http://stackoverflow.com/questions/28264313/ssl-certificates-and-b奧斯特-ASIO)。 –
你可以添加一個斷點並添加更多關於導致消息的'ec'對象的信息嗎?另外,你有沒有嘗試其他網站?如果您可以通過http站點重現問題,則可以嘗試使用wireshark檢查網絡通信。 – roschuma