Skip to content

Commit 2e68b97

Browse files
committed
WIP
1 parent fa08e90 commit 2e68b97

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

lib/base/tlsstream.hpp

+28-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#include <boost/asio/ssl/context.hpp>
2121
#include <boost/asio/ssl/stream.hpp>
2222

23+
#ifdef _WIN32
24+
# include <boost/wintls.hpp>
25+
#endif /* _WIN32 */
26+
2327
namespace icinga
2428
{
2529

@@ -63,7 +67,30 @@ struct UnbufferedAsioTlsStreamParams
6367
const String& Hostname;
6468
};
6569

66-
typedef SeenStream<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> AsioTcpTlsStream;
70+
#ifdef _WIN32
71+
template<class T>
72+
class TlsStream : public boost::wintls::stream<T>
73+
{
74+
public:
75+
using boost::wintls::stream<T>::stream;
76+
77+
typedef typename next_layer_type::lowest_layer_type lowest_layer_type;
78+
typedef boost::wintls::handshake_type handshake_type;
79+
80+
static constexpr auto client = boost::wintls::handshake_type::client;
81+
static constexpr auto server = boost::wintls::handshake_type::server;
82+
83+
lowest_layer_type& lowest_layer()
84+
{
85+
return next_layer().lowest_layer();
86+
}
87+
};
88+
#else /* _WIN32 */
89+
template<class T>
90+
using TlsStream = boost::asio::ssl::stream<T>;
91+
#endif /* _WIN32 */
92+
93+
typedef SeenStream<TlsStream<boost::asio::ip::tcp::socket>> AsioTcpTlsStream;
6794

6895
class UnbufferedAsioTlsStream : public AsioTcpTlsStream
6996
{

lib/base/tlsutility.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include <boost/asio/ssl/context.hpp>
2323
#include <boost/exception/info.hpp>
2424

25+
#ifdef _WIN32
26+
# include <boost/wintls/context.hpp>
27+
#endif /* _WIN32 */
28+
2529
namespace icinga
2630
{
2731

@@ -38,7 +42,11 @@ const auto LEAF_VALID_FOR = 60 * 60 * 24 * 397;
3842
const auto RENEW_THRESHOLD = 60 * 60 * 24 * 30;
3943
const auto RENEW_INTERVAL = 60 * 60 * 24;
4044

45+
#ifdef _WIN32
46+
typedef boost::wintls::context TlsContext;
47+
#else /* _WIN32 */
4148
typedef boost::asio::ssl::context TlsContext;
49+
#endif /* _WIN32 */
4250

4351
void InitializeOpenSSL();
4452

0 commit comments

Comments
 (0)