2

cpprestsdk "Casablanca" マスター ブランチを https URL で使用しています。Windows と osx の両方で動作していますが、Linux で実行すると "Error is ssl handshake" というメッセージが表示されました。

C++ exception with description "Error in SSL handshake" thrown in the test body.

動作するFirefoxを使用してこのURLを開こうとしました。

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);
        }
    }

クライアント側では、このようにhttpクライアントを作成しました

http_client client(U("https://www.bing.com/"));

このエラーを修正するにはどうすればよいですか?

4

1 に答える 1