Skip to content

Commit

Permalink
Move library out of boost namespace
Browse files Browse the repository at this point in the history
This library is now called asio.wintls instead of boost.wintls as it
no longer depends on boost.

Since this library does not require boost remove the boost namespace
and simply use the wintls namespace.

Update the documentation to reflect that change and refer to asio
instead of boost asio where it makes most sense.
  • Loading branch information
laudrup committed Feb 18, 2024
1 parent 812740b commit 838b58b
Show file tree
Hide file tree
Showing 91 changed files with 573 additions and 653 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ include(VersionFromGit)

version_from_git()

project(boost-wintls
project(wintls
VERSION ${VERSION}
DESCRIPTION "Native Windows TLS stream for Boost.Asio"
DESCRIPTION "Native Windows TLS stream for Asio"
HOMEPAGE_URL "https://wintls.dev/"
LANGUAGES CXX
)
Expand Down
53 changes: 33 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<img width="800" height = "80" alt = "Boost.Wintls Logo" src="https://raw.githubusercontent.com/laudrup/boost-wintls/master/doc/logo.jpg">
<img width="800" height="80" alt="Asio.Wintls Logo" src="https://raw.githubusercontent.com/laudrup/boost-wintls/master/doc/logo.jpg">

# Native Windows TLS stream for Boost.Asio
# Native Windows TLS stream for Asio

<a href="https://www.stopputin.net/">
<img style="display: block; margin-left: 20%; margin-right: auto; width: 7%" alt = "Support Ukraine" src="https://raw.githubusercontent.com/laudrup/boost-wintls/master/doc/support-ukraine.png">
<img style="display: block; margin-left: 20%; margin-right: auto; width: 7%;" alt="Support Ukraine" src="https://raw.githubusercontent.com/laudrup/boost-wintls/master/doc/support-ukraine.png">
</a>

[wintls.dev](https://wintls.dev/)
Expand All @@ -25,9 +25,10 @@ Build | Coverage | Coverity Analysis |
## Introduction

Implements a TLS stream wrapper for use with
[Asio](https://think-async.com/Asio/) or
[Boost.Asio](https://www.boost.org/doc/libs/release/doc/html/boost_asio.html)
similar to
[Boost.Asio.SSL](https://www.boost.org/doc/libs/release/doc/html/boost_asio/overview/ssl.html)
[Asio.SSL](https://www.boost.org/doc/libs/release/doc/html/boost_asio/overview/ssl.html)
but using native Windows API
([SSPI/Schannel](https://docs.microsoft.com/en-us/windows-server/security/tls/tls-ssl-schannel-ssp-overview))
functionality instead of OpenSSL for providing TLS encrypted stream functionality.
Expand All @@ -36,13 +37,18 @@ functionality instead of OpenSSL for providing TLS encrypted stream functionalit

As this library uses Windows specific libraries, it is only supported
on Microsoft Windows although it is intended to be used alongside the
existing Boost.Asio.SSL implementation.
existing Asio.SSL implementation.

[Boost](https://www.boost.org) is required. Currently tested with
Boost 1.80 to 1.83 but most newer versions ought to work.
Code using this library must target at least
[Windows 7 (NT 6.1)](https://learn.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers).

A working C++ compiler supporting the C++14 standard is required.
Currently tested compilers are:
Either [Asio](https://think-async.com/Asio/) or the [Boost
libraries](https://www.boost.org) are required. Currently tested with
Boost 1.80 to 1.83 and Asio 1.28 to 1.29 but at least most newer
versions ought to work.

A working C++ compiler supporting at least the C++14 standard is
required. Currently tested compilers are:

- MSVC for Visual Studio 2022
- MSVC for Visual Studio 2019
Expand All @@ -51,10 +57,10 @@ Currently tested compilers are:

## Building

Boost.Wintls is header-only. To use it just add the necessary `#include` line
Asio.Wintls is header-only. To use it just add the necessary `#include` line
to your source files, like this:
```C++
#include <boost/wintls.hpp>
#include <wintls.hpp>
```

CMake may be used to generate a Visual Studio solution for building
Expand All @@ -71,29 +77,34 @@ If the provided CMake scripts are not used and you are using the
MinGW64 compiler the `crypt32`, `secur32`, `ws2_32` and `wsock32`
libraries needs to be linked with your libraries/executables.

Currently this library expects the Boost libraries to be available
(i.e. found in the include path). If standalone Asio is to be used
instead, define `#WINTLS_USE_STANDALONE_ASIO` before including
`wintls.hpp` and make sure that Asio is found in the include path
instead.

## Quickstart

Similar to Boost.Asio.SSL a
[boost::wintls::context](https://laudrup.github.io/boost-wintls/classes.html#context)
Similar to Asio.SSL a
[wintls::context](https://wintls.dev/classes.html#context)
is required to hold certificates and options to use for the TLS
stream:

```C++
// Set up context to use the systems default TLS methods (e.g. TLS 1.2)
boost::wintls::context ctx{boost::wintls::method::system_default};
wintls::context ctx{wintls::method::system_default};
```
Using that context a
[boost::wintls::stream](https://laudrup.github.io/boost-wintls/classes.html#stream)
[wintls::stream](https://wintls.dev/classes.html#stream)
can be constructed using a
[boost::asio::io_context](https://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/io_context.html)
specifying the underlying stream type (most often a TCP stream):
```C++
boost::asio::io_context ioc;
boost::wintls::stream<boost::asio::ip::tcp::socket> stream(ioc, ctx);
wintls::stream<boost::asio::ip::tcp::socket> stream(ioc, ctx);
```

Although that is all that is required to construct a stream that fully
Expand All @@ -106,18 +117,20 @@ to be performed and most likely, certificates and keys has to be
handled as well.

For details on how to do that, please see the
[documentation](https://laudrup.github.io/boost-wintls) and the
[examples](https://laudrup.github.io/boost-wintls/examples.html)
[documentation](https://wintls.dev) and the
[examples](https://wintls.dev/examples.html)

## Documentation

Documentation is available [here](https://laudrup.github.io/boost-wintls).
Documentation is available [here](https://wintls.dev/).

## Contributing

Pull requests, issue reporting etc. are very much welcome.

If you use this library and find it useful, I would love to know. You should also consider donating to one of the funds that help victims of the war in Ukraine:
If you use this library and find it useful, I would love to know. You
should also consider donating to one of the funds that help victims of
the war in Ukraine:

[https://www.stopputin.net/](https://www.stopputin.net/)

Expand Down
6 changes: 3 additions & 3 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
find_package(Doxygen REQUIRED)
find_package(Sphinx REQUIRED)

set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/include/boost/wintls/)
set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/include/wintls/)
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/index.xml)
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
Expand Down Expand Up @@ -50,12 +50,12 @@ set(SPHINX_SOURCE_FILES
add_custom_command(OUTPUT ${SPHINX_INDEX_FILE}
COMMAND
${SPHINX_EXECUTABLE} -b html
-D breathe_projects.boost-wintls=${DOXYGEN_OUTPUT_DIR}
-D breathe_projects.wintls=${DOXYGEN_OUTPUT_DIR}
-D version=${PROJECT_VERSION}
${SPHINX_SOURCE} ${SPHINX_BUILD}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/static/boost-wintls.css
${CMAKE_CURRENT_SOURCE_DIR}/static/wintls.css
${CMAKE_CURRENT_SOURCE_DIR}/templates/layout.html
${CMAKE_CURRENT_SOURCE_DIR}/templates/navbar.html
${CMAKE_CURRENT_SOURCE_DIR}/extensions/toctree_elements.py
Expand Down
4 changes: 2 additions & 2 deletions doc/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Classes

context
-------
.. doxygenclass:: boost::wintls::context
.. doxygenclass:: wintls::context
:members:

stream
------
.. doxygenclass:: boost::wintls::stream
.. doxygenclass:: wintls::stream
:members:
6 changes: 3 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

sys.path.append(os.path.abspath("./extensions"))

project = 'boost-wintls'
project = 'wintls'
copyright = '2021, Kasper Laudrup'
author = 'Kasper Laudrup'

Expand All @@ -24,7 +24,7 @@

html_static_path = ['static']

html_title = 'boost.wintls'
html_title = 'asio.wintls'

html_css_files = [
project + '.css',
Expand All @@ -40,4 +40,4 @@

html_last_updated_fmt = ''

breathe_default_project = 'boost-wintls'
breathe_default_project = 'wintls'
6 changes: 3 additions & 3 deletions doc/enumerations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Enumerations

handshake_type
--------------
.. doxygenenum:: boost::wintls::handshake_type
.. doxygenenum:: wintls::handshake_type

method
------
.. doxygenenum:: boost::wintls::method
.. doxygenenum:: wintls::method

file_format
-----------
.. doxygenenum:: boost::wintls::file_format
.. doxygenenum:: wintls::file_format
8 changes: 4 additions & 4 deletions doc/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Functions

x509_to_cert_context
--------------------
.. doxygenfunction:: boost::wintls::x509_to_cert_context(const net::const_buffer &x509, file_format format)
.. doxygenfunction:: boost::wintls::x509_to_cert_context(const net::const_buffer &x509, file_format format, boost::system::error_code& ec)
.. doxygenfunction:: wintls::x509_to_cert_context(const net::const_buffer &x509, file_format format)
.. doxygenfunction:: wintls::x509_to_cert_context(const net::const_buffer &x509, file_format format, boost::system::error_code& ec)

import_private_key
------------------
.. doxygenfunction:: boost::wintls::import_private_key(const net::const_buffer& private_key, file_format format, const std::string& name)
.. doxygenfunction:: boost::wintls::import_private_key(const net::const_buffer& private_key, file_format format, const std::string& name, boost::system::error_code& ec)
.. doxygenfunction:: wintls::import_private_key(const net::const_buffer& private_key, file_format format, const std::string& name)
.. doxygenfunction:: wintls::import_private_key(const net::const_buffer& private_key, file_format format, const std::string& name, boost::system::error_code& ec)

delete_private_key
------------------
Expand Down
19 changes: 10 additions & 9 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
.. figure:: logo.jpg
:alt: Boost.Wintls logo
:alt: Wintls logo

Overview
========

This library implements TLS stream functionality for `boost::asio`_
using native Windows `SSPI/Schannel`_ implementation.
This library implements TLS stream functionality for `asio`_ or
`boost::asio`_ using native Windows `SSPI/Schannel`_ implementation.

To the extend possible it provides the same functionality as the
`OpenSSL`_ implementation used by `boost::asio`_ and provides some
helper :ref:`functions<functions>` for converting and managing certificates and keys in
standard formats used by `OpenSSL`_.
`OpenSSL`_ implementation used by `asio`_ and provides some helper
:ref:`functions<functions>` for converting and managing certificates
and keys in standard formats used by `OpenSSL`_.

Released under the `Boost Software License`_. Source code available on `GitHub`_.

Motivation
----------

`boost::asio`_ uses `OpenSSL`_ for TLS encryption which has a few
downsides when used on Windows:
`asio`_ uses `OpenSSL`_ for TLS encryption which has a few downsides
when used on Windows:

* Requires maintaining a separate copy of trusted certificate
authorities although the operating system already ships with and
Expand All @@ -32,7 +32,7 @@ downsides when used on Windows:
* Installing third party libraries and software in general on Windows
is often a complicated process since no central packaging system
exists, so any security updates to `OpenSSL`_ would have to be
maintained by the software using the `boost::asio`_ library.
maintained by the software using the `asio`_ library.

This library avoids these issues by using the native Windows TLS
implementation (`SSPI/SChannel`_) which uses the methods for storing
Expand All @@ -48,6 +48,7 @@ Contents
API


.. _asio: https://think-async.com/Asio/
.. _SSPI/Schannel: https://docs.microsoft.com/en-us/windows-server/security/tls/tls-ssl-schannel-ssp-overview/
.. _OpenSSL: https://www.openssl.org/
.. _boost::asio: https://www.boost.org/doc/libs/release/doc/html/boost_asio.html
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion doc/type_aliases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Type aliases

cert_context_ptr
----------------
.. doxygentypedef:: boost::wintls::cert_context_ptr
.. doxygentypedef:: wintls::cert_context_ptr

.. _CERT_CONTEXT: https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/ns-wincrypt-cert_context
14 changes: 7 additions & 7 deletions doc/usage.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. cpp:namespace:: boost::wintls
.. cpp:namespace:: wintls

Usage
=====
Expand All @@ -21,9 +21,9 @@ to support.
To construct a context using the operating system default methods:
::

#include <boost/wintls.hpp>
#include <wintls.hpp>

boost::wintls::context ctx(boost::wintls::method::system_default);
wintls::context ctx(wintls::method::system_default);

While that is all which is required to construct a context for
client-side operations, most users would at least want to enable
Expand All @@ -37,9 +37,9 @@ provided by the operating system and verify the server certificate,
would look something like:
::

#include <boost/wintls.hpp>
#include <wintls.hpp>

boost::wintls::context ctx(boost::wintls::method::system_default);
wintls::context ctx(wintls::method::system_default);
ctx.use_default_certificates(true);
ctx.verify_server_certificate(true);

Expand All @@ -64,7 +64,7 @@ Assuming an underlying TCP stream, once the context has been setup
a :class:`stream` can be constructed like:
::

boost::wintls::stream<ip::tcp::socket> my_stream(my_io_service, ctx);
wintls::stream<ip::tcp::socket> my_stream(my_io_service, ctx);

In the case of a TCP stream, the underlying stream needs to be
connected before it can be used. To access the underlying stream use
Expand All @@ -87,7 +87,7 @@ like:
::

strean.set_server_hostname("wintls.dev");
stream.handshake(boost::wintls::handshake_type::client);
stream.handshake(wintls::handshake_type::client);

Similar to the `boost::asio`_ functions, this library provides
overloads for accepting a `boost::system`_::error_codes.
Expand Down
8 changes: 4 additions & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ add_executable(echo_client echo_client.cpp)
add_executable(echo_server echo_server.cpp)

target_link_libraries(echo_server PRIVATE
boost-wintls
wintls
)

target_link_libraries(echo_client PRIVATE
boost-wintls
wintls
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
Expand All @@ -19,11 +19,11 @@ if(NOT ENABLE_WINTLS_STANDALONE_ASIO)
add_executable(async_https_client async_https_client.cpp)

target_link_libraries(https_client PRIVATE
boost-wintls
wintls
)

target_link_libraries(async_https_client PRIVATE
boost-wintls
wintls
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
Expand Down
Loading

0 comments on commit 838b58b

Please sign in to comment.