@@ -282,6 +282,10 @@ namespace web { namespace http
282
282
boost::asio::deadline_timer m_timeout_timer;
283
283
std::shared_ptr<linux_connection> m_connection;
284
284
285
+ #if defined(__APPLE__) || defined(ANDROID)
286
+ bool m_openssl_failed;
287
+ #endif
288
+
285
289
virtual ~linux_client_request_context ();
286
290
287
291
void handle_timeout_timer (const boost::system::error_code& ec)
@@ -449,9 +453,6 @@ namespace web { namespace http
449
453
450
454
private:
451
455
tcp::resolver m_resolver;
452
- #if defined(__APPLE__) || defined(ANDROID)
453
- bool m_openssl_failed;
454
- #endif
455
456
456
457
static bool _check_streambuf (std::shared_ptr<linux_client_request_context> ctx, concurrency::streams::streambuf<uint8_t > rdbuf, const utility::char_t * msg)
457
458
{
@@ -482,9 +483,9 @@ namespace web { namespace http
482
483
if (client_config ().validate_certificates ())
483
484
{
484
485
ctx->m_ssl_stream ->set_verify_mode (boost::asio::ssl::context::verify_peer);
485
- ctx->m_ssl_stream ->set_verify_callback (boost::bind (&linux_client::handle_cert_verification, shared_from_this (), _1, _2));
486
+ ctx->m_ssl_stream ->set_verify_callback (boost::bind (&linux_client::handle_cert_verification, shared_from_this (), _1, _2, ctx ));
486
487
#if defined(__APPLE__) || defined(ANDROID)
487
- m_openssl_failed = false ;
488
+ ctx-> m_openssl_failed = false ;
488
489
#endif
489
490
}
490
491
else
@@ -544,8 +545,11 @@ namespace web { namespace http
544
545
}
545
546
}
546
547
547
- bool handle_cert_verification (bool preverified, boost::asio::ssl::verify_context &ctx )
548
+ bool handle_cert_verification (bool preverified, boost::asio::ssl::verify_context &verifyCtx, std::shared_ptr<linux_client_request_context> requestCtx )
548
549
{
550
+ // Unreferenced parameter on some platforms.
551
+ requestCtx;
552
+
549
553
// OpenSSL calls the verification callback once per certificate in the chain,
550
554
// starting with the root CA certificate. The 'leaf', non-Certificate Authority (CA)
551
555
// certificate, i.e. actual server certificate is at the '0' position in the
@@ -555,15 +559,15 @@ namespace web { namespace http
555
559
#if defined(__APPLE__) || defined(ANDROID)
556
560
if (!preverified)
557
561
{
558
- m_openssl_failed = true ;
562
+ requestCtx-> m_openssl_failed = true ;
559
563
}
560
- if (m_openssl_failed)
564
+ if (requestCtx-> m_openssl_failed )
561
565
{
562
566
// On OS X, iOS, and Android, OpenSSL doesn't have access to where the OS
563
567
// stores keychains. If OpenSSL fails we will doing verification at the
564
568
// end using the whole certificate chain so wait until the 'leaf' cert.
565
569
// For now return true so OpenSSL continues down the certificate chain.
566
- X509_STORE_CTX *storeContext = ctx .native_handle ();
570
+ X509_STORE_CTX *storeContext = verifyCtx .native_handle ();
567
571
int currentDepth = X509_STORE_CTX_get_error_depth (storeContext);
568
572
if (currentDepth != 0 )
569
573
{
@@ -607,7 +611,7 @@ namespace web { namespace http
607
611
#endif
608
612
609
613
boost::asio::ssl::rfc2818_verification rfc2818 (m_uri.host ());
610
- return rfc2818 (preverified, ctx );
614
+ return rfc2818 (preverified, verifyCtx );
611
615
}
612
616
613
617
void handle_handshake (const boost::system::error_code& ec, std::shared_ptr<linux_client_request_context> ctx)
@@ -1170,6 +1174,9 @@ namespace web { namespace http
1170
1174
, m_timedout(false )
1171
1175
, m_timeout_timer(crossplat::threadpool::shared_instance().service())
1172
1176
, m_connection(std::move(connection))
1177
+ #if defined(__APPLE__) || defined(ANDROID)
1178
+ , m_openssl_failed(false )
1179
+ #endif
1173
1180
{}
1174
1181
1175
1182
std::shared_ptr<request_context> linux_client_request_context::create_request_context (
0 commit comments