From c90e92744350aad9ce092381b8c1ff62589e87e8 Mon Sep 17 00:00:00 2001 From: Amit Saraf Date: Thu, 19 Dec 2019 11:45:23 -0800 Subject: [PATCH 1/7] Disable TLS version 1.0 & 1.1. --- Release/src/http/client/http_client_asio.cpp | 11 +++++++++-- Release/src/http/client/http_client_winhttp.cpp | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index 3b5b602230..ae59106dbf 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -138,13 +138,19 @@ class asio_connection // This simply instantiates the internal state to support ssl. It does not perform the handshake. void upgrade_to_ssl(const std::function& ssl_context_callback) { + std::cout << "======================= inside upgrade_to_ssl" << std::endl; std::lock_guard lock(m_socket_lock); assert(!is_ssl()); - boost::asio::ssl::context ssl_context(boost::asio::ssl::context::sslv23); + boost::asio::ssl::context ssl_context(boost::asio::ssl::context::tlsv12); ssl_context.set_default_verify_paths(); - ssl_context.set_options(boost::asio::ssl::context::default_workarounds); + ssl_context.set_options(boost::asio::ssl::context::default_workarounds | + boost::asio::ssl::context::no_sslv2 | + boost::asio::ssl::context::no_sslv3 | + boost::asio::ssl::context::no_tlsv1 | + boost::asio::ssl::context::no_tlsv1_1); if (ssl_context_callback) { + std::cout << "======================= setting tls version 1.2" << std::endl; ssl_context_callback(ssl_context); } m_ssl_stream = utility::details::make_unique>(m_socket, ssl_context); @@ -426,6 +432,7 @@ class asio_client final : public _http_client_communicator { // Pool was empty. Create a new connection conn = std::make_shared>(crossplat::threadpool::shared_instance().service()); + std::cout << "*************** creating new web socket connection" << std::endl; if (m_start_with_ssl) conn->upgrade_to_ssl(this->client_config().get_ssl_context_callback()); } diff --git a/Release/src/http/client/http_client_winhttp.cpp b/Release/src/http/client/http_client_winhttp.cpp index 06dedd3069..4f25c42e07 100644 --- a/Release/src/http/client/http_client_winhttp.cpp +++ b/Release/src/http/client/http_client_winhttp.cpp @@ -539,7 +539,7 @@ class winhttp_client : public _http_client_communicator #if !defined(CPPREST_TARGET_XP) BOOL win32_result(FALSE); - DWORD secure_protocols(WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2); + DWORD secure_protocols(WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2); win32_result = ::WinHttpSetOption(m_hSession, WINHTTP_OPTION_SECURE_PROTOCOLS, &secure_protocols, sizeof(secure_protocols)); if(FALSE == win32_result) { @@ -1561,4 +1561,4 @@ std::shared_ptr<_http_client_communicator> create_winhttp_client(uri&& base_uri, } }}}} - + From c2f1f7cb0a629dbe344d6aa027f90e43e0d3ad87 Mon Sep 17 00:00:00 2001 From: Amit Saraf Date: Thu, 19 Dec 2019 14:09:29 -0800 Subject: [PATCH 2/7] fix linux compilation --- Release/src/http/client/http_client_asio.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index ae59106dbf..87fba078ab 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -146,8 +146,7 @@ class asio_connection ssl_context.set_options(boost::asio::ssl::context::default_workarounds | boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::no_sslv3 | - boost::asio::ssl::context::no_tlsv1 | - boost::asio::ssl::context::no_tlsv1_1); + boost::asio::ssl::context::no_tlsv1); if (ssl_context_callback) { std::cout << "======================= setting tls version 1.2" << std::endl; From 4a65f7e5255025cf7f3e6cc6f9d29cbfd8f5c979 Mon Sep 17 00:00:00 2001 From: Amit Saraf Date: Thu, 19 Dec 2019 15:16:50 -0800 Subject: [PATCH 3/7] use tls 1.1 --- Release/src/http/client/http_client_asio.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index 87fba078ab..f4c1df1e6f 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -141,7 +141,7 @@ class asio_connection std::cout << "======================= inside upgrade_to_ssl" << std::endl; std::lock_guard lock(m_socket_lock); assert(!is_ssl()); - boost::asio::ssl::context ssl_context(boost::asio::ssl::context::tlsv12); + boost::asio::ssl::context ssl_context(boost::asio::ssl::context::tlsv11); ssl_context.set_default_verify_paths(); ssl_context.set_options(boost::asio::ssl::context::default_workarounds | boost::asio::ssl::context::no_sslv2 | @@ -149,7 +149,7 @@ class asio_connection boost::asio::ssl::context::no_tlsv1); if (ssl_context_callback) { - std::cout << "======================= setting tls version 1.2" << std::endl; + std::cout << "======================= setting tls version 1.1" << std::endl; ssl_context_callback(ssl_context); } m_ssl_stream = utility::details::make_unique>(m_socket, ssl_context); From df2e4360f84e609482b1095892e1a75fe2d784d8 Mon Sep 17 00:00:00 2001 From: Amit Saraf Date: Thu, 19 Dec 2019 15:54:19 -0800 Subject: [PATCH 4/7] use tls 1.2 --- .vscode/settings.json | 88 ++++++++++++++++++++ Release/src/http/client/http_client_asio.cpp | 4 +- 2 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..db9d026b65 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,88 @@ +{ + "files.associations": { + "algorithm": "cpp", + "array": "cpp", + "atomic": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "complex": "cpp", + "condition_variable": "cpp", + "csetjmp": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "exception": "cpp", + "resumable": "cpp", + "fstream": "cpp", + "functional": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "iterator": "cpp", + "limits": "cpp", + "list": "cpp", + "locale": "cpp", + "map": "cpp", + "memory": "cpp", + "mutex": "cpp", + "new": "cpp", + "optional": "cpp", + "ostream": "cpp", + "queue": "cpp", + "random": "cpp", + "ratio": "cpp", + "set": "cpp", + "shared_mutex": "cpp", + "sstream": "cpp", + "stack": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "xthread": "cpp", + "thread": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeindex": "cpp", + "typeinfo": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "utility": "cpp", + "variant": "cpp", + "vector": "cpp", + "xfacet": "cpp", + "xhash": "cpp", + "xiosbase": "cpp", + "xlocale": "cpp", + "xlocbuf": "cpp", + "xlocinfo": "cpp", + "xlocmes": "cpp", + "xlocmon": "cpp", + "xlocnum": "cpp", + "xloctime": "cpp", + "xmemory": "cpp", + "xmemory0": "cpp", + "xstddef": "cpp", + "xstring": "cpp", + "xtr1common": "cpp", + "xtree": "cpp", + "xutility": "cpp" + } +} \ No newline at end of file diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index f4c1df1e6f..87fba078ab 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -141,7 +141,7 @@ class asio_connection std::cout << "======================= inside upgrade_to_ssl" << std::endl; std::lock_guard lock(m_socket_lock); assert(!is_ssl()); - boost::asio::ssl::context ssl_context(boost::asio::ssl::context::tlsv11); + boost::asio::ssl::context ssl_context(boost::asio::ssl::context::tlsv12); ssl_context.set_default_verify_paths(); ssl_context.set_options(boost::asio::ssl::context::default_workarounds | boost::asio::ssl::context::no_sslv2 | @@ -149,7 +149,7 @@ class asio_connection boost::asio::ssl::context::no_tlsv1); if (ssl_context_callback) { - std::cout << "======================= setting tls version 1.1" << std::endl; + std::cout << "======================= setting tls version 1.2" << std::endl; ssl_context_callback(ssl_context); } m_ssl_stream = utility::details::make_unique>(m_socket, ssl_context); From e5b01f55253e8c8697cc2b76b88b6d7ca1f30f34 Mon Sep 17 00:00:00 2001 From: Amit Saraf Date: Thu, 19 Dec 2019 16:08:09 -0800 Subject: [PATCH 5/7] code clean up --- Release/src/http/client/http_client_asio.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index 87fba078ab..0c26a608fe 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -138,7 +138,6 @@ class asio_connection // This simply instantiates the internal state to support ssl. It does not perform the handshake. void upgrade_to_ssl(const std::function& ssl_context_callback) { - std::cout << "======================= inside upgrade_to_ssl" << std::endl; std::lock_guard lock(m_socket_lock); assert(!is_ssl()); boost::asio::ssl::context ssl_context(boost::asio::ssl::context::tlsv12); @@ -149,7 +148,6 @@ class asio_connection boost::asio::ssl::context::no_tlsv1); if (ssl_context_callback) { - std::cout << "======================= setting tls version 1.2" << std::endl; ssl_context_callback(ssl_context); } m_ssl_stream = utility::details::make_unique>(m_socket, ssl_context); @@ -431,7 +429,6 @@ class asio_client final : public _http_client_communicator { // Pool was empty. Create a new connection conn = std::make_shared>(crossplat::threadpool::shared_instance().service()); - std::cout << "*************** creating new web socket connection" << std::endl; if (m_start_with_ssl) conn->upgrade_to_ssl(this->client_config().get_ssl_context_callback()); } From 95250537311539d454b5f8c94829af52352b945e Mon Sep 17 00:00:00 2001 From: Amit Saraf Date: Thu, 19 Dec 2019 16:11:05 -0800 Subject: [PATCH 6/7] code clean up --- .vscode/settings.json | 88 ------------------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index db9d026b65..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "files.associations": { - "algorithm": "cpp", - "array": "cpp", - "atomic": "cpp", - "bitset": "cpp", - "cctype": "cpp", - "chrono": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "codecvt": "cpp", - "complex": "cpp", - "condition_variable": "cpp", - "csetjmp": "cpp", - "csignal": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "exception": "cpp", - "resumable": "cpp", - "fstream": "cpp", - "functional": "cpp", - "future": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "ios": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "iterator": "cpp", - "limits": "cpp", - "list": "cpp", - "locale": "cpp", - "map": "cpp", - "memory": "cpp", - "mutex": "cpp", - "new": "cpp", - "optional": "cpp", - "ostream": "cpp", - "queue": "cpp", - "random": "cpp", - "ratio": "cpp", - "set": "cpp", - "shared_mutex": "cpp", - "sstream": "cpp", - "stack": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "string": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "xthread": "cpp", - "thread": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "typeindex": "cpp", - "typeinfo": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "utility": "cpp", - "variant": "cpp", - "vector": "cpp", - "xfacet": "cpp", - "xhash": "cpp", - "xiosbase": "cpp", - "xlocale": "cpp", - "xlocbuf": "cpp", - "xlocinfo": "cpp", - "xlocmes": "cpp", - "xlocmon": "cpp", - "xlocnum": "cpp", - "xloctime": "cpp", - "xmemory": "cpp", - "xmemory0": "cpp", - "xstddef": "cpp", - "xstring": "cpp", - "xtr1common": "cpp", - "xtree": "cpp", - "xutility": "cpp" - } -} \ No newline at end of file From ebf448a899e35545dd124c28bef08b04460cd2cd Mon Sep 17 00:00:00 2001 From: Amit Saraf Date: Thu, 19 Dec 2019 16:13:16 -0800 Subject: [PATCH 7/7] code clean up --- Release/src/http/client/http_client_asio.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index 0c26a608fe..ca45295f40 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -144,8 +144,7 @@ class asio_connection ssl_context.set_default_verify_paths(); ssl_context.set_options(boost::asio::ssl::context::default_workarounds | boost::asio::ssl::context::no_sslv2 | - boost::asio::ssl::context::no_sslv3 | - boost::asio::ssl::context::no_tlsv1); + boost::asio::ssl::context::no_sslv3); if (ssl_context_callback) { ssl_context_callback(ssl_context);