Feature/mbedtls (#84)
* try to import mbedtls and build it * add stubs socket class * some boilterplate, read and write function implemented * more boilterplate / current error in handshake because no CA cert is setup * add something so skip ca verification, can ws curl https://google.com ! * cleanup / close implemented * tweak CMakefiles * typo in include * update readme * disable unittests
This commit is contained in:
committed by
GitHub
parent
ba4a9e1586
commit
06cbebe22e
47
ixwebsocket/IXSocketMbedTLS.h
Normal file
47
ixwebsocket/IXSocketMbedTLS.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* IXSocketMbedTLS.h
|
||||
* Author: Benjamin Sergeant
|
||||
* Copyright (c) 2017-2018 Machine Zone, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "IXSocket.h"
|
||||
#include <mbedtls/ctr_drbg.h>
|
||||
#include <mbedtls/debug.h>
|
||||
#include <mbedtls/entropy.h>
|
||||
#include <mbedtls/error.h>
|
||||
#include <mbedtls/net.h>
|
||||
#include <mbedtls/platform.h>
|
||||
#include <mutex>
|
||||
|
||||
namespace ix
|
||||
{
|
||||
class SocketMbedTLS final : public Socket
|
||||
{
|
||||
public:
|
||||
SocketMbedTLS() = default;
|
||||
~SocketMbedTLS();
|
||||
|
||||
virtual bool connect(const std::string& host,
|
||||
int port,
|
||||
std::string& errMsg,
|
||||
const CancellationRequest& isCancellationRequested) final;
|
||||
virtual void close() final;
|
||||
|
||||
virtual ssize_t send(char* buffer, size_t length) final;
|
||||
virtual ssize_t send(const std::string& buffer) final;
|
||||
virtual ssize_t recv(void* buffer, size_t length) final;
|
||||
|
||||
private:
|
||||
mbedtls_ssl_context _ssl;
|
||||
mbedtls_ssl_config _conf;
|
||||
mbedtls_entropy_context _entropy;
|
||||
mbedtls_ctr_drbg_context _ctr_drbg;
|
||||
|
||||
std::mutex _mutex;
|
||||
|
||||
bool init(const std::string& host, std::string& errMsg);
|
||||
};
|
||||
|
||||
} // namespace ix
|
Reference in New Issue
Block a user