diff --git a/Release/include/cpprest/ws_client.h b/Release/include/cpprest/ws_client.h
index b6d00b805d..6ce052342e 100644
--- a/Release/include/cpprest/ws_client.h
+++ b/Release/include/cpprest/ws_client.h
@@ -84,7 +84,11 @@ class websocket_client_config
///
/// Creates a websocket client configuration with default settings.
///
- websocket_client_config() : m_sni_enabled(true) {}
+ websocket_client_config() :
+ m_sni_enabled(true),
+ m_validate_certificates(true)
+ {
+ }
///
/// Get the web proxy object
@@ -187,6 +191,25 @@ class websocket_client_config
/// If you want all the subprotocols in a comma separated string
/// they can be directly looked up in the headers using 'Sec-WebSocket-Protocol'.
_ASYNCRTIMP std::vector<::utility::string_t> subprotocols() const;
+
+ ///
+ /// Gets the server certificate validation property.
+ ///
+ /// True if certificates are to be verified, false otherwise.
+ bool validate_certificates() const
+ {
+ return m_validate_certificates;
+ }
+
+ ///
+ /// Sets the server certificate validation property.
+ ///
+ /// False to turn ignore all server certificate validation errors, true otherwise.
+ /// Note ignoring certificate errors can be dangerous and should be done with caution.
+ void set_validate_certificates(bool validate_certs)
+ {
+ m_validate_certificates = validate_certs;
+ }
private:
web::web_proxy m_proxy;
@@ -194,6 +217,7 @@ class websocket_client_config
web::http::http_headers m_headers;
bool m_sni_enabled;
utf8string m_sni_hostname;
+ bool m_validate_certificates;
};
///
diff --git a/Release/src/websockets/client/ws_client_wspp.cpp b/Release/src/websockets/client/ws_client_wspp.cpp
index 6b5971e481..9f91d68d59 100644
--- a/Release/src/websockets/client/ws_client_wspp.cpp
+++ b/Release/src/websockets/client/ws_client_wspp.cpp
@@ -180,7 +180,14 @@ class wspp_callback_client : public websocket_client_callback_impl, public std::
auto sslContext = websocketpp::lib::shared_ptr(new boost::asio::ssl::context(boost::asio::ssl::context::sslv23));
sslContext->set_default_verify_paths();
sslContext->set_options(boost::asio::ssl::context::default_workarounds);
- sslContext->set_verify_mode(boost::asio::ssl::context::verify_peer);
+ if (m_config.validate_certificates())
+ {
+ sslContext->set_verify_mode(boost::asio::ssl::context::verify_peer);
+ }
+ else
+ {
+ sslContext->set_verify_mode(boost::asio::ssl::context::verify_none);
+ }
#if defined(__APPLE__) || (defined(ANDROID) || defined(__ANDROID__)) || defined(_WIN32)
m_openssl_failed = false;