Skip to content

Commit 3751cbf

Browse files
committed
Merge branch 'development' of https://git01.codeplex.com/casablanca into boost_http_client_misc
Conflicts: Release/src/http/client/http_linux.cpp
2 parents 7ecf721 + bad74a2 commit 3751cbf

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

Release/src/http/client/http_linux.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ namespace web { namespace http
281281
boost::asio::deadline_timer m_timeout_timer;
282282
std::shared_ptr<linux_connection> m_connection;
283283

284+
#if defined(__APPLE__) || defined(ANDROID)
285+
bool m_openssl_failed;
286+
#endif
287+
284288
virtual ~linux_client_request_context();
285289

286290
void handle_timeout_timer(const boost::system::error_code& ec)
@@ -432,9 +436,6 @@ namespace web { namespace http
432436

433437
private:
434438
tcp::resolver m_resolver;
435-
#if defined(__APPLE__) || defined(ANDROID)
436-
bool m_openssl_failed;
437-
#endif
438439

439440
// Helper function to create ssl stream and set verification options.
440441
void reset_ssl_stream(const std::shared_ptr<linux_client_request_context> &ctx)
@@ -448,9 +449,9 @@ namespace web { namespace http
448449
if (client_config().validate_certificates())
449450
{
450451
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));
452453
#if defined(__APPLE__) || defined(ANDROID)
453-
m_openssl_failed = false;
454+
ctx->m_openssl_failed = false;
454455
#endif
455456
}
456457
else
@@ -472,7 +473,7 @@ namespace web { namespace http
472473
}
473474
}
474475

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)
476477
{
477478
if (ctx->m_ssl_stream)
478479
{
@@ -484,7 +485,7 @@ namespace web { namespace http
484485
}
485486
}
486487

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)
488489
{
489490
if (!ec)
490491
{
@@ -510,8 +511,11 @@ namespace web { namespace http
510511
}
511512
}
512513

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)
514515
{
516+
// Unreferenced parameter on some platforms.
517+
requestCtx;
518+
515519
// OpenSSL calls the verification callback once per certificate in the chain,
516520
// starting with the root CA certificate. The 'leaf', non-Certificate Authority (CA)
517521
// certificate, i.e. actual server certificate is at the '0' position in the
@@ -521,15 +525,15 @@ namespace web { namespace http
521525
#if defined(__APPLE__) || defined(ANDROID)
522526
if(!preverified)
523527
{
524-
m_openssl_failed = true;
528+
requestCtx->m_openssl_failed = true;
525529
}
526-
if(m_openssl_failed)
530+
if(requestCtx->m_openssl_failed)
527531
{
528532
// On OS X, iOS, and Android, OpenSSL doesn't have access to where the OS
529533
// stores keychains. If OpenSSL fails we will doing verification at the
530534
// end using the whole certificate chain so wait until the 'leaf' cert.
531535
// 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();
533537
int currentDepth = X509_STORE_CTX_get_error_depth(storeContext);
534538
if(currentDepth != 0)
535539
{
@@ -573,7 +577,7 @@ namespace web { namespace http
573577
#endif
574578

575579
boost::asio::ssl::rfc2818_verification rfc2818(m_uri.host());
576-
return rfc2818(preverified, ctx);
580+
return rfc2818(preverified, verifyCtx);
577581
}
578582

579583
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
11341138
, m_timedout(false)
11351139
, m_timeout_timer(crossplat::threadpool::shared_instance().service())
11361140
, m_connection(connection)
1141+
#if defined(__APPLE__) || defined(ANDROID)
1142+
, m_openssl_failed(false)
1143+
#endif
11371144
{}
11381145

11391146
std::shared_ptr<request_context> linux_client_request_context::create_request_context(

Release/tests/Functional/http/client/connections_and_errors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ TEST_FIXTURE(uri_address, cancel_while_uploading_data, "Ignore:Linux", "220", "I
328328

329329
// This test can't be implemented with our test server since it doesn't stream data so isn't avaliable on WinRT.
330330
#ifndef __cplusplus_winrt
331-
TEST_FIXTURE(uri_address, cancel_while_downloading_data)
331+
TEST_FIXTURE(uri_address, cancel_while_downloading_data, "Ignore:Apple", "220")
332332
{
333333
web::http::experimental::listener::http_listener listener(m_uri);
334334
listener.open().wait();

casablanca120.desktop.sln

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.30501.0
4+
VisualStudioVersion = 12.0.30723.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "casablanca120.xp", "Release\src\build\casablanca120.xp.vcxproj", "{15F3B200-1AED-4B57-AF37-B21CD67914B1}"
77
EndProject
@@ -50,8 +50,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SearchFile120", "Release\sa
5050
{1014C621-BC2D-4813-B8C1-6D83AD6F9249} = {1014C621-BC2D-4813-B8C1-6D83AD6F9249}
5151
EndProjectSection
5252
EndProject
53-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "codeplex165", "..\codeplex165\codeplex165.vcxproj", "{70E24896-422E-4CB4-B671-94D33D60BA1A}"
54-
EndProject
5553
Global
5654
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5755
Debug|ARM = Debug|ARM
@@ -154,14 +152,6 @@ Global
154152
{F03BEE03-BEFB-4B17-A774-D9C8246530D4}.Release|Win32.Build.0 = Release|Win32
155153
{F03BEE03-BEFB-4B17-A774-D9C8246530D4}.Release|x64.ActiveCfg = Release|x64
156154
{F03BEE03-BEFB-4B17-A774-D9C8246530D4}.Release|x64.Build.0 = Release|x64
157-
{70E24896-422E-4CB4-B671-94D33D60BA1A}.Debug|ARM.ActiveCfg = Debug|Win32
158-
{70E24896-422E-4CB4-B671-94D33D60BA1A}.Debug|Win32.ActiveCfg = Debug|Win32
159-
{70E24896-422E-4CB4-B671-94D33D60BA1A}.Debug|Win32.Build.0 = Debug|Win32
160-
{70E24896-422E-4CB4-B671-94D33D60BA1A}.Debug|x64.ActiveCfg = Debug|Win32
161-
{70E24896-422E-4CB4-B671-94D33D60BA1A}.Release|ARM.ActiveCfg = Release|Win32
162-
{70E24896-422E-4CB4-B671-94D33D60BA1A}.Release|Win32.ActiveCfg = Release|Win32
163-
{70E24896-422E-4CB4-B671-94D33D60BA1A}.Release|Win32.Build.0 = Release|Win32
164-
{70E24896-422E-4CB4-B671-94D33D60BA1A}.Release|x64.ActiveCfg = Release|Win32
165155
EndGlobalSection
166156
GlobalSection(SolutionProperties) = preSolution
167157
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)