Skip to content

Commit 5caac61

Browse files
committed
Initial work to get secure websocket_client on Windows desktop.
1 parent 1530786 commit 5caac61

File tree

3 files changed

+6
-20
lines changed

3 files changed

+6
-20
lines changed

Release/src/websockets/client/ws_client.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@
5757
#else
5858
#define _WEBSOCKETPP_NULLPTR_TOKEN_ 0
5959
#endif
60-
#ifndef _MS_WINDOWS
6160
#include <websocketpp/config/asio_client.hpp>
62-
#endif
6361
#include <websocketpp/config/asio_no_tls_client.hpp>
6462
#include <websocketpp/client.hpp>
6563
#pragma warning( pop )
@@ -152,7 +150,6 @@ class wspp_client : public _websocket_client_impl, public std::enable_shared_fro
152150

153151
pplx::task<void> connect()
154152
{
155-
#ifndef _MS_WINDOWS
156153
if (m_uri.scheme() == U("wss"))
157154
{
158155
m_client = std::unique_ptr<websocketpp_client_base>(new websocketpp_tls_client());
@@ -184,16 +181,17 @@ class wspp_client : public _websocket_client_impl, public std::enable_shared_fro
184181
return http::client::details::verify_cert_chain_platform_specific(verifyCtx, m_uri.host());
185182
}
186183
#endif
187-
boost::asio::ssl::rfc2818_verification rfc2818(m_uri.host());
188-
return rfc2818(preverified, verifyCtx);
184+
boost::asio::ssl::rfc2818_verification rfc2818(utility::conversions::to_utf8string(m_uri.host()));
185+
/*return*/ rfc2818(preverified, verifyCtx);
186+
// TODO
187+
return true;
189188
});
190189

191190
return sslContext;
192191
});
193192
return connect_impl<websocketpp::config::asio_tls_client>();
194193
}
195194
else
196-
#endif
197195
{
198196
m_client = std::unique_ptr<websocketpp_client_base>(new websocketpp_client());
199197
return connect_impl<websocketpp::config::asio_client>();
@@ -402,13 +400,11 @@ class wspp_client : public _websocket_client_impl, public std::enable_shared_fro
402400

403401
void send_msg(websocket_outgoing_message &msg)
404402
{
405-
#ifndef _MS_WINDOWS
406403
if (m_client->is_tls_client())
407404
{
408405
send_msg_impl<websocketpp::config::asio_tls_client>(msg);
409406
}
410407
else
411-
#endif
412408
{
413409
send_msg_impl<websocketpp::config::asio_client>(msg);
414410
}
@@ -575,13 +571,11 @@ class wspp_client : public _websocket_client_impl, public std::enable_shared_fro
575571

576572
pplx::task<void> close(websocket_close_status status, const utility::string_t& reason)
577573
{
578-
#ifndef _MS_WINDOWS
579574
if (m_client->is_tls_client())
580575
{
581576
return close_impl<websocketpp::config::asio_tls_client>(status, reason);
582577
}
583578
else
584-
#endif
585579
{
586580
return close_impl<websocketpp::config::asio_client>(status, reason);
587581
}
@@ -633,13 +627,11 @@ class wspp_client : public _websocket_client_impl, public std::enable_shared_fro
633627
template <typename WebsocketConfig>
634628
websocketpp::client<WebsocketConfig> & client()
635629
{
636-
#ifndef _MS_WINDOWS
637630
if(is_tls_client())
638631
{
639632
return reinterpret_cast<websocketpp::client<WebsocketConfig> &>(tls_client());
640633
}
641634
else
642-
#endif
643635
{
644636
return reinterpret_cast<websocketpp::client<WebsocketConfig> &>(non_tls_client());
645637
}
@@ -648,12 +640,10 @@ class wspp_client : public _websocket_client_impl, public std::enable_shared_fro
648640
{
649641
throw std::bad_cast();
650642
}
651-
#ifndef _MS_WINDOWS
652643
virtual websocketpp::client<websocketpp::config::asio_tls_client> & tls_client()
653644
{
654645
throw std::bad_cast();
655646
}
656-
#endif
657647
virtual bool is_tls_client() const = 0;
658648
};
659649
struct websocketpp_client : websocketpp_client_base
@@ -665,7 +655,6 @@ class wspp_client : public _websocket_client_impl, public std::enable_shared_fro
665655
bool is_tls_client() const override { return false; }
666656
websocketpp::client<websocketpp::config::asio_client> m_client;
667657
};
668-
#ifndef _MS_WINDOWS
669658
struct websocketpp_tls_client : websocketpp_client_base
670659
{
671660
websocketpp::client<websocketpp::config::asio_tls_client> & tls_client() override
@@ -675,7 +664,6 @@ class wspp_client : public _websocket_client_impl, public std::enable_shared_fro
675664
bool is_tls_client() const override { return true; }
676665
websocketpp::client<websocketpp::config::asio_tls_client> m_client;
677666
};
678-
#endif
679667
std::unique_ptr<websocketpp_client_base> m_client;
680668

681669
websocketpp::connection_hdl m_con;

Release/tests/Functional/websockets/client/authentication_tests.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ TEST_FIXTURE(uri_address, auth_no_credentials, "Ignore", "245")
7575
TEST_FIXTURE(uri_address, auth_with_credentials, "Ignore", "245")
7676
{
7777
test_websocket_server server;
78-
websocket_client_config config;
78+
websocket_client_config config;
7979
web::credentials cred(U("user"), U("password"));
8080
config.set_credentials(cred);
8181
websocket_client client(config);
@@ -86,8 +86,6 @@ TEST_FIXTURE(uri_address, auth_with_credentials, "Ignore", "245")
8686
}
8787
#endif
8888

89-
// Secure websockets on implemented yet on non-WinRT Windows - 255
90-
#if defined(__cplusplus_winrt) || !defined(_MS_WINDOWS)
9189
TEST_FIXTURE(uri_address, ssl_test)
9290
{
9391
websocket_client client;
@@ -110,7 +108,6 @@ TEST_FIXTURE(uri_address, ssl_test)
110108
receive_task.wait();
111109
client.close().wait();
112110
}
113-
#endif
114111

115112
} // SUITE(authentication_tests)
116113

Release/tests/Functional/websockets/client/vs12/websocketsclient120_test.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
<ClInclude Include="..\websocket_client_tests.h" />
117117
</ItemGroup>
118118
<ItemGroup>
119+
<ClCompile Include="..\authentication_tests.cpp" />
119120
<ClCompile Include="..\client_construction.cpp" />
120121
<ClCompile Include="..\close_tests.cpp" />
121122
<ClCompile Include="..\error_tests.cpp" />

0 commit comments

Comments
 (0)