@@ -281,6 +281,10 @@ namespace web { namespace http
281
281
boost::asio::deadline_timer m_timeout_timer;
282
282
std::shared_ptr<linux_connection> m_connection;
283
283
284
+ #if defined(__APPLE__) || defined(ANDROID)
285
+ bool m_openssl_failed;
286
+ #endif
287
+
284
288
virtual ~linux_client_request_context ();
285
289
286
290
void handle_timeout_timer (const boost::system::error_code& ec)
@@ -432,9 +436,6 @@ namespace web { namespace http
432
436
433
437
private:
434
438
tcp::resolver m_resolver;
435
- #if defined(__APPLE__) || defined(ANDROID)
436
- bool m_openssl_failed;
437
- #endif
438
439
439
440
// Helper function to create ssl stream and set verification options.
440
441
void reset_ssl_stream (const std::shared_ptr<linux_client_request_context> &ctx)
@@ -448,9 +449,9 @@ namespace web { namespace http
448
449
if (client_config ().validate_certificates ())
449
450
{
450
451
ctx->m_ssl_stream ->set_verify_mode (boost::asio::ssl::context::verify_peer);
451
- ctx->m_ssl_stream ->set_verify_callback (boost::bind (&linux_client::handle_cert_verification, shared_from_this (), _1, _2));
452
+ ctx->m_ssl_stream ->set_verify_callback (boost::bind (&linux_client::handle_cert_verification, shared_from_this (), _1, _2, ctx ));
452
453
#if defined(__APPLE__) || defined(ANDROID)
453
- m_openssl_failed = false ;
454
+ ctx-> m_openssl_failed = false ;
454
455
#endif
455
456
}
456
457
else
@@ -472,7 +473,7 @@ namespace web { namespace http
472
473
}
473
474
}
474
475
475
- void write_request (std::shared_ptr<linux_client_request_context> &ctx)
476
+ void write_request (const std::shared_ptr<linux_client_request_context> &ctx)
476
477
{
477
478
if (ctx->m_ssl_stream )
478
479
{
@@ -484,7 +485,7 @@ namespace web { namespace http
484
485
}
485
486
}
486
487
487
- void handle_connect (const boost::system::error_code& ec, tcp::resolver::iterator endpoints, std::shared_ptr<linux_client_request_context> ctx)
488
+ void handle_connect (const boost::system::error_code& ec, tcp::resolver::iterator endpoints, const std::shared_ptr<linux_client_request_context> & ctx)
488
489
{
489
490
if (!ec)
490
491
{
@@ -510,8 +511,11 @@ namespace web { namespace http
510
511
}
511
512
}
512
513
513
- bool handle_cert_verification (bool preverified, boost::asio::ssl::verify_context &ctx )
514
+ bool handle_cert_verification (bool preverified, boost::asio::ssl::verify_context &verifyCtx, const std::shared_ptr<linux_client_request_context> &requestCtx )
514
515
{
516
+ // Unreferenced parameter on some platforms.
517
+ requestCtx;
518
+
515
519
// OpenSSL calls the verification callback once per certificate in the chain,
516
520
// starting with the root CA certificate. The 'leaf', non-Certificate Authority (CA)
517
521
// certificate, i.e. actual server certificate is at the '0' position in the
@@ -521,15 +525,15 @@ namespace web { namespace http
521
525
#if defined(__APPLE__) || defined(ANDROID)
522
526
if (!preverified)
523
527
{
524
- m_openssl_failed = true ;
528
+ requestCtx-> m_openssl_failed = true ;
525
529
}
526
- if (m_openssl_failed)
530
+ if (requestCtx-> m_openssl_failed )
527
531
{
528
532
// On OS X, iOS, and Android, OpenSSL doesn't have access to where the OS
529
533
// stores keychains. If OpenSSL fails we will doing verification at the
530
534
// end using the whole certificate chain so wait until the 'leaf' cert.
531
535
// For now return true so OpenSSL continues down the certificate chain.
532
- X509_STORE_CTX *storeContext = ctx .native_handle ();
536
+ X509_STORE_CTX *storeContext = verifyCtx .native_handle ();
533
537
int currentDepth = X509_STORE_CTX_get_error_depth (storeContext);
534
538
if (currentDepth != 0 )
535
539
{
@@ -573,7 +577,7 @@ namespace web { namespace http
573
577
#endif
574
578
575
579
boost::asio::ssl::rfc2818_verification rfc2818 (m_uri.host ());
576
- return rfc2818 (preverified, ctx );
580
+ return rfc2818 (preverified, verifyCtx );
577
581
}
578
582
579
583
void handle_handshake (const boost::system::error_code& ec, std::shared_ptr<linux_client_request_context> ctx)
@@ -1134,6 +1138,9 @@ namespace web { namespace http
1134
1138
, m_timedout(false )
1135
1139
, m_timeout_timer(crossplat::threadpool::shared_instance().service())
1136
1140
, m_connection(connection)
1141
+ #if defined(__APPLE__) || defined(ANDROID)
1142
+ , m_openssl_failed(false )
1143
+ #endif
1137
1144
{}
1138
1145
1139
1146
std::shared_ptr<request_context> linux_client_request_context::create_request_context (
0 commit comments