Skip to content

Client/Server Secure ConnectionProvider for oatpp applications. Based on MbedTLS.

License

Notifications You must be signed in to change notification settings

oatpp/oatpp-mbedtls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oatpp-mbedtls Build Status

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:

How To Build

Requires

  • MbedTLS installed.

Install MbedTLS from source

git clone -b 'mbedtls-2.16.1' --single-branch --depth 1 --recurse-submodules https://github.com/ARMmbed/mbedtls

cd mbedtls
mkdir build && cd build

cmake ..
make install

Install MbedTLS to a custom location

git clone -b 'mbedtls-2.16.1' --single-branch --depth 1 --recurse-submodules https://github.com/ARMmbed/mbedtls

cd mbedtls
mkdir build && cd build

cmake -DCMAKE_INSTALL_PREFIX:PATH=/my/custom/location ..
make install

Build And Install oatpp-mbedtls

If mbedtls was installed to a standard location:

mkdir build && cd build
cmake ..
make install

If mbedtls was installed to a custom location:

mkdir build && cd build
cmake -DMBEDTLS_ROOT_DIR=/my/custom/location ..
make install

APIs

Server

ConnectionProvider

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, {"localhost" /* host */, 443 /* port */});

/* Get Secure Connection Stream */
auto connection = connectionProvider->getConnection();

Custom Transport Stream

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::tcp::server::ConnectionProvider::createShared({"localhost" /* host */, 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:

Client

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();

Custom Transport Stream

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:

See more