mbedtls fixes / the unittest now pass on macOS, and hopefully will on Windows/AppVeyor as well.

This commit is contained in:
Benjamin Sergeant 2019-09-27 14:07:01 -07:00
parent 0499a80c55
commit 1b6584ccba
7 changed files with 26 additions and 11 deletions

View File

@ -1,6 +1,10 @@
# Changelog # Changelog
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [6.2.9] - 2019-09-27
- mbedtls fixes / the unittest now pass on macOS, and hopefully will on Windows/AppVeyor as well.
## [6.2.8] - 2019-09-26 ## [6.2.8] - 2019-09-26
- Http server: add options to ws https to redirect all requests to a given url. POST requests will get a 200 and an empty response. - Http server: add options to ws https to redirect all requests to a given url. POST requests will get a 200 and an empty response.

View File

@ -195,6 +195,10 @@ namespace snake
}; };
auto responseCallback = [ws, pdu, &subscriptionId](const std::string& redisResponse) { auto responseCallback = [ws, pdu, &subscriptionId](const std::string& redisResponse) {
std::stringstream ss;
ss << "Redis Response: " << redisResponse << "...";
ix::IXCoreLogger::Log(ss.str().c_str());
// Success // Success
nlohmann::json response = {{"action", "rtm/subscribe/ok"}, nlohmann::json response = {{"action", "rtm/subscribe/ok"},
{"id", pdu.value("id", 1)}, {"id", pdu.value("id", 1)},

View File

@ -153,10 +153,9 @@ namespace ix
// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections
// //
setOnConnectionCallback( setOnConnectionCallback(
[this, redirectUrl]( [this,
HttpRequestPtr request, redirectUrl](HttpRequestPtr request,
std::shared_ptr<ConnectionState> /*connectionState*/) -> HttpResponsePtr { std::shared_ptr<ConnectionState> /*connectionState*/) -> HttpResponsePtr {
WebSocketHttpHeaders headers; WebSocketHttpHeaders headers;
headers["Server"] = userAgent(); headers["Server"] = userAgent();

View File

@ -20,25 +20,31 @@ namespace ix
SocketMbedTLS::SocketMbedTLS(const SocketTLSOptions& tlsOptions) SocketMbedTLS::SocketMbedTLS(const SocketTLSOptions& tlsOptions)
: _tlsOptions(tlsOptions) : _tlsOptions(tlsOptions)
{ {
; initMBedTLS();
} }
SocketMbedTLS::~SocketMbedTLS() SocketMbedTLS::~SocketMbedTLS()
{ {
close(); SocketMbedTLS::close();
} }
bool SocketMbedTLS::init(const std::string& host, std::string& errMsg) void SocketMbedTLS::initMBedTLS()
{ {
std::lock_guard<std::mutex> lock(_mutex); std::lock_guard<std::mutex> lock(_mutex);
mbedtls_ssl_init(&_ssl); mbedtls_ssl_init(&_ssl);
mbedtls_ssl_config_init(&_conf); mbedtls_ssl_config_init(&_conf);
mbedtls_ctr_drbg_init(&_ctr_drbg); mbedtls_ctr_drbg_init(&_ctr_drbg);
mbedtls_entropy_init(&_entropy);
}
bool SocketMbedTLS::init(const std::string& host, std::string& errMsg)
{
initMBedTLS();
std::lock_guard<std::mutex> lock(_mutex);
const char* pers = "IXSocketMbedTLS"; const char* pers = "IXSocketMbedTLS";
mbedtls_entropy_init(&_entropy);
if (mbedtls_ctr_drbg_seed(&_ctr_drbg, if (mbedtls_ctr_drbg_seed(&_ctr_drbg,
mbedtls_entropy_func, mbedtls_entropy_func,
&_entropy, &_entropy,
@ -89,7 +95,8 @@ namespace ix
if (_sockfd == -1) return false; if (_sockfd == -1) return false;
} }
if (!init(host, errMsg)) bool initialized = init(host, errMsg);
if (!initialized)
{ {
close(); close();
return false; return false;

View File

@ -44,6 +44,7 @@ namespace ix
SocketTLSOptions _tlsOptions; SocketTLSOptions _tlsOptions;
bool init(const std::string& host, std::string& errMsg); bool init(const std::string& host, std::string& errMsg);
void initMBedTLS();
}; };
} // namespace ix } // namespace ix

View File

@ -6,4 +6,4 @@
#pragma once #pragma once
#define IX_WEBSOCKET_VERSION "6.2.8" #define IX_WEBSOCKET_VERSION "6.2.9"

View File

@ -10,7 +10,7 @@
using namespace ix; using namespace ix;
TEST_CASE("http client", "[http]") TEST_CASE("http_client", "[http]")
{ {
SECTION("Connect to a remote HTTP server") SECTION("Connect to a remote HTTP server")
{ {