compiled fixes on mac and windows

This commit is contained in:
Benjamin Sergeant 2019-09-22 18:43:57 -07:00
parent 408ee41990
commit 041fa3e340
6 changed files with 21 additions and 4 deletions

View File

@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.
## [6.2.4] - 2019-09-22
- Add options to configure TLS ; contributed by Matt DeBoer. Only implemented for OpenSSL TLS backend for now.
## [6.2.3] - 2019-09-21
- Fix crash in the Linux unittest in the HTTP client code, in Socket::readBytes

View File

@ -141,8 +141,9 @@ std::string getSSLErrorDescription(OSStatus status)
namespace ix
{
SocketAppleSSL::SocketAppleSSL(int fd) : Socket(fd),
_sslContext(nullptr)
SocketAppleSSL::SocketAppleSSL(const SocketTLSOptions& tlsOptions, int fd) : Socket(fd),
_sslContext(nullptr),
_tlsOptions(tlsOptions)
{
;
}

View File

@ -8,6 +8,7 @@
#include "IXCancellationRequest.h"
#include "IXSocket.h"
#include "IXSocketTLSOptions.h"
#include <Security/SecureTransport.h>
#include <Security/Security.h>
#include <mutex>
@ -17,7 +18,7 @@ namespace ix
class SocketAppleSSL final : public Socket
{
public:
SocketAppleSSL(int fd = -1);
SocketAppleSSL(const SocketTLSOptions& tlsOptions, int fd = -1);
~SocketAppleSSL();
virtual bool connect(const std::string& host,
@ -33,6 +34,8 @@ namespace ix
private:
SSLContextRef _sslContext;
mutable std::mutex _mutex; // AppleSSL routines are not thread-safe
SocketTLSOptions _tlsOptions;
};
} // namespace ix

View File

@ -17,6 +17,12 @@
namespace ix
{
SocketMbedTLS(const SocketTLSOptions& tlsOptions) :
_tlsOptions(tlsOptions)
{
;
}
SocketMbedTLS::~SocketMbedTLS()
{
close();

View File

@ -7,6 +7,7 @@
#pragma once
#include "IXSocket.h"
#include "IXSocketTLSOptions.h"
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
@ -20,7 +21,7 @@ namespace ix
class SocketMbedTLS final : public Socket
{
public:
SocketMbedTLS() = default;
SocketMbedTLS(const SocketTLSOptions& tlsOptions);
~SocketMbedTLS();
virtual bool connect(const std::string& host,
@ -40,6 +41,7 @@ namespace ix
mbedtls_ctr_drbg_context _ctr_drbg;
std::mutex _mutex;
SocketTLSOptions _tlsOptions;
bool init(const std::string& host, std::string& errMsg);
};

View File

@ -22,6 +22,7 @@ namespace ix
SocketOpenSSL::SocketOpenSSL(const SocketTLSOptions& tlsOptions, int fd)
: Socket(fd)
, _tlsOptions(tlsOptions),
, _ssl_connection(nullptr)
, _ssl_context(nullptr)
{