From d0963f4af07891e3850f8b39ae5adaeb11decaa3 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Sun, 22 Sep 2019 18:43:57 -0700 Subject: [PATCH] compiled fixes on mac and windows --- docs/CHANGELOG.md | 4 ++++ ixwebsocket/IXSocketAppleSSL.cpp | 5 +++-- ixwebsocket/IXSocketAppleSSL.h | 5 ++++- ixwebsocket/IXSocketMbedTLS.cpp | 6 ++++++ ixwebsocket/IXSocketMbedTLS.h | 4 +++- ixwebsocket/IXSocketOpenSSL.cpp | 1 + 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 1bb1761c..38b93bb6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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 diff --git a/ixwebsocket/IXSocketAppleSSL.cpp b/ixwebsocket/IXSocketAppleSSL.cpp index 1f6d73db..0a74cb78 100644 --- a/ixwebsocket/IXSocketAppleSSL.cpp +++ b/ixwebsocket/IXSocketAppleSSL.cpp @@ -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) { ; } diff --git a/ixwebsocket/IXSocketAppleSSL.h b/ixwebsocket/IXSocketAppleSSL.h index 2fdc30d8..02977761 100644 --- a/ixwebsocket/IXSocketAppleSSL.h +++ b/ixwebsocket/IXSocketAppleSSL.h @@ -8,6 +8,7 @@ #include "IXCancellationRequest.h" #include "IXSocket.h" +#include "IXSocketTLSOptions.h" #include #include #include @@ -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 diff --git a/ixwebsocket/IXSocketMbedTLS.cpp b/ixwebsocket/IXSocketMbedTLS.cpp index 91d696c1..aff905a3 100644 --- a/ixwebsocket/IXSocketMbedTLS.cpp +++ b/ixwebsocket/IXSocketMbedTLS.cpp @@ -17,6 +17,12 @@ namespace ix { + SocketMbedTLS(const SocketTLSOptions& tlsOptions) : + _tlsOptions(tlsOptions) + { + ; + } + SocketMbedTLS::~SocketMbedTLS() { close(); diff --git a/ixwebsocket/IXSocketMbedTLS.h b/ixwebsocket/IXSocketMbedTLS.h index b5a04535..c6a0d3d9 100644 --- a/ixwebsocket/IXSocketMbedTLS.h +++ b/ixwebsocket/IXSocketMbedTLS.h @@ -7,6 +7,7 @@ #pragma once #include "IXSocket.h" +#include "IXSocketTLSOptions.h" #include #include #include @@ -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); }; diff --git a/ixwebsocket/IXSocketOpenSSL.cpp b/ixwebsocket/IXSocketOpenSSL.cpp index c30db9d2..d5740ac2 100644 --- a/ixwebsocket/IXSocketOpenSSL.cpp +++ b/ixwebsocket/IXSocketOpenSSL.cpp @@ -22,6 +22,7 @@ namespace ix SocketOpenSSL::SocketOpenSSL(const SocketTLSOptions& tlsOptions, int fd) : Socket(fd) + , _tlsOptions(tlsOptions), , _ssl_connection(nullptr) , _ssl_context(nullptr) {