oatpp-mbedtls - extension for Oat++ Web Framework.
It provides secure server and client connection providers for oatpp applications. Based on MbedTLS.
Supports both "Simple" and "Async" oatpp APIs.
See more:
Create ConnectionProvider
const char* serverCertificateFile = "path/to/server/certificate";
const char* serverPrivateKeyFile = "path/to/server/private/key";
/* Create Config */
auto config = oatpp::mbedtls::Config::createDefaultServerConfigShared(serverCertificateFile, serverPrivateKeyFile);
/* Create Secure Connection Provider */
auto connectionProvider = oatpp::mbedtls::server::ConnectionProvider::createShared(config, 443 /* port */);
/* Get Secure Connection Stream */
auto connection = connectionProvider->getConnection();
Create ConnectionProvider
with custom transport stream.
const char* serverCertificateFile = "path/to/server/certificate";
const char* serverPrivateKeyFile = "path/to/server/private/key";
/* Create Config */
auto config = oatpp::mbedtls::Config::createDefaultServerConfigShared(serverCertificateFile, serverPrivateKeyFile);
/* Create Transport Stream Provider */
/* Replace With Your Custom Transport Stream Provider */
auto transportStreamProvider = oatpp::network::server::SimpleTCPConnectionProvider::createShared(443 /* port */);
/* Create Secure Connection Provider */
auto connectionProvider = oatpp::mbedtls::server::ConnectionProvider::createShared(config, transportStreamProvider);
/* Get Secure Connection Stream over Custom Transport Stream */
auto connection = connectionProvider->getConnection();
Note: To use oatpp-mbedtls
for server connections with custom transport stream you should implement:
- oatpp::network::ServerConnectionProvider.
- oatpp::data::stream::IOStream - to be returned by
ConnectionProvider
.
Create ConnectionProvider
/* Create Config */
auto config = oatpp::mbedtls::Config::createDefaultClientConfigShared();
/* Create Secure Connection Provider */
auto connectionProvider = oatpp::mbedtls::client::ConnectionProvider::createShared(config, "httpbin.org", 443 /* port */);
/* Get Secure Connection Stream */
auto connection = connectionProvider->getConnection();
Create ConnectionProvider
with custom transport stream.
/* Create Config */
auto config = oatpp::mbedtls::Config::createDefaultClientConfigShared();
/* Create Transport Stream Provider */
/* Replace With Your Custom Transport Stream Provider */
auto transportStreamProvider = oatpp::network::client::SimpleTCPConnectionProvider::createShared("httpbin.org", 443 /* port */);
/* Create Secure Connection Provider */
auto connectionProvider = oatpp::mbedtls::client::ConnectionProvider::createShared(config, transportStreamProvider);
/* Get Secure Connection Stream over Custom Transport Stream */
auto connection = connectionProvider->getConnection();
Note: To use oatpp-mbedtls
for client connections with custom transport stream you should implement:
- oatpp::network::ClientConnectionProvider.
- oatpp::data::stream::IOStream - to be returned by
ConnectionProvider
.