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

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

View File

@ -20,25 +20,31 @@ namespace ix
SocketMbedTLS::SocketMbedTLS(const SocketTLSOptions& tlsOptions)
: _tlsOptions(tlsOptions)
{
;
initMBedTLS();
}
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);
mbedtls_ssl_init(&_ssl);
mbedtls_ssl_config_init(&_conf);
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";
mbedtls_entropy_init(&_entropy);
if (mbedtls_ctr_drbg_seed(&_ctr_drbg,
mbedtls_entropy_func,
&_entropy,
@ -89,7 +95,8 @@ namespace ix
if (_sockfd == -1) return false;
}
if (!init(host, errMsg))
bool initialized = init(host, errMsg);
if (!initialized)
{
close();
return false;

View File

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

View File

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