openTLS is a fork of https://causal.agency/libretls/, which is a port of libtls from LibreSSL to OpenSSL. libtls is "a new TLS library, designed to make it easier to write foolproof applications".
libtls provides an excellent new API, but LibreSSL can be difficult to install on systems which already use OpenSSL. openTLS aims to make the libtls API more easily and widely available.
See Writing TLS secured client and server programs using the libtls API and libtls: Rethinking the TLS/SSL API.
openTLS is based on LibreSSL-portable sources. openTLS releases track LibreSSL releases, starting with version 3.9.2.
The libtls provided by openTLS is ABI-compatible with the libtls provided by the corresponding LibreSSL release.
The behavior of openTLS and LibreSSL differs in how the root certificates are loaded by default.
LibreSSL uses a hardcoded path to a CA bundle file, while openTLS uses the default CA locations of OpenSSL,
which may include a CA directory. To restore the behavior of LibreSSL, call tls_config_set_ca_file(3)
with the path returned by tls_default_ca_cert_file(3). All other behaviors should be identical.
openTLS targets the OpenSSL 1.1.0 series. openTLS is compatible with OpenSSL 3.0.0 but hasn't been ported away from deprecated APIs.
openTLS should work on the same platforms as LibreSSL-portable.
libtls consists of all new code developed as part of OpenBSD under OpenBSD's preferred license of ISC. Some compat sources are under the 3-clause BSD license or the MIT license.
The build system uses cmake, that produces static libraries by default.
Linux
mkdir build
cd build
cmake .. -D CMAKE_BUILD_TYPE=Debug/Release -D BUILD_TESTS=ON # use to build files in tests folder
cmake --build .Windows
mkdir build
cd build
cmake .. -D BUILD_EXAMPLES=ON -D BUILD_TESTS=ON # use to build files in tests folder
cmake --build . --config Debug/ReleaseAs cmake project dependency
Add to CMakeLists.txt
find_package(opentls QUIET)
if(NOT opentls_FOUND)
FetchContent_Declare(opentls
URL https://github.com/zelang-dev/opentls/archive/refs/tags/4.1.12.zip
URL_MD5 0d95f587b35fa12991e42d763cf5f5bf
)
FetchContent_MakeAvailable(opentls)
endif()
target_include_directories(your_project PUBLIC $<BUILD_INTERFACE:${OPENSSL_INCLUDE_DIR}
$<INSTALL_INTERFACE:${OPENSSL_INCLUDE_DIR})
target_include_directories(your_project PUBLIC ${OPENTLS_INCLUDE_DIR}
$<INSTALL_INTERFACE:${OPENTLS_INCLUDE_DIR})
target_link_libraries(your_project PUBLIC ${OPENSSL_SSL_LIBRARY})
target_link_libraries(your_project PUBLIC ${OPENSSL_CRYPTO_LIBRARY})
target_link_libraries(your_project PUBLIC opentls)