|
join 1.0
lightweight network framework library
|
basic TLS/DTLS decorator. More...
#include <tls.hpp>


Public Types | |
| using | UnderlyingSocket = typename Protocol::Transport::Socket |
| using | Mode = typename UnderlyingSocket::Mode |
| using | Option = typename UnderlyingSocket::Option |
| using | State = typename UnderlyingSocket::State |
| using | Endpoint = typename Protocol::Endpoint |
| using | TimePoint = typename UnderlyingSocket::TimePoint |
Public Member Functions | |
| BasicTls (TlsContext ctx, Mode mode=Mode::NonBlocking) noexcept | |
| create a TLS decorator with an internally created socket. | |
| BasicTls (UnderlyingSocket &&socket) noexcept | |
| create a TLS decorator taking ownership of the given socket, without context. | |
| BasicTls (UnderlyingSocket &&socket, TlsContext ctx) noexcept | |
| create a TLS decorator taking ownership of the given socket. | |
| BasicTls (const BasicTls &other)=delete | |
| copy constructor. | |
| BasicTls & | operator= (const BasicTls &other)=delete |
| copy assignment operator. | |
| BasicTls (BasicTls &&other) noexcept | |
| move constructor. | |
| BasicTls & | operator= (BasicTls &&other) noexcept |
| move assignment operator. | |
| virtual | ~BasicTls ()=default |
| destroy the instance. | |
| int | open (const Protocol &protocol=Protocol()) noexcept |
| open the underlying socket using the given protocol. | |
| bool | opened () const noexcept |
| check if the underlying socket is opened. | |
| int | bind (const Endpoint &ep) noexcept |
| assigns the specified endpoint to the underlying socket. | |
| int | bindToDevice (const std::string &dev) noexcept |
| assigns the specified device to the underlying socket. | |
| int | connect (const Endpoint &ep) noexcept |
| connect the underlying socket to the remote endpoint. | |
| bool | connected () noexcept |
| check if the underlying socket is connected. | |
| int | deferHandshake () |
| set the TLS layer up without negotiating immediately. | |
| int | handshake () |
| perform the TLS handshake. | |
| bool | waitHandshake () |
| block until TLS handshake is finished. | |
| bool | waitHandshake (std::chrono::nanoseconds timeout) |
| block until TLS handshake is finished, giving up after the given duration. | |
| virtual bool | waitHandshake (TimePoint deadline) |
| block until TLS handshake is finished, giving up at the given time point. | |
| bool | encrypted () const noexcept |
| check if the stream is encrypted. | |
| int | shutdown () noexcept |
| Perform the TLS shutdown. | |
| bool | waitShutdown () noexcept |
| block until TLS shutdown is finished. | |
| bool | waitShutdown (std::chrono::nanoseconds timeout) noexcept |
| block until TLS shutdown is finished, giving up after the given duration. | |
| bool | waitShutdown (TimePoint deadline) noexcept |
| block until TLS shutdown is finished, giving up at the given time point. | |
| int | disconnect () noexcept |
| disconnect the underlying socket from the remote endpoint. | |
| void | close () noexcept |
| close the socket handle. | |
| bool | waitReadyRead () const noexcept |
| block until new data is available for reading. | |
| bool | waitReadyRead (std::chrono::nanoseconds timeout) const noexcept |
| block until new data is available for reading, giving up after the given duration. | |
| bool | waitReadyRead (TimePoint deadline) const noexcept |
| block until new data is available for reading, giving up at the given time point. | |
| ssize_t | read (char *buf, size_t len) noexcept |
| read data from the TLS stream. | |
| int | readExactly (char *data, size_t size) |
| read data until size is reached or an error occurred. | |
| int | readExactly (char *data, size_t size, std::chrono::nanoseconds timeout) |
| read data until size is reached, an error occurred or the given duration elapsed. | |
| int | readExactly (char *data, size_t size, TimePoint deadline) |
| read data until size is reached, an error occurred or the deadline expired. | |
| bool | waitReadyWrite () const noexcept |
| block until at least one byte can be written on the socket. | |
| bool | waitReadyWrite (std::chrono::nanoseconds timeout) const noexcept |
| block until at least one byte can be written on the socket, giving up after the given duration. | |
| bool | waitReadyWrite (TimePoint deadline) const noexcept |
| block until at least one byte can be written, giving up at the given time point. | |
| ssize_t | write (const char *buf, size_t len) noexcept |
| write data to the TLS stream. | |
| int | writeExactly (const char *data, size_t size) |
| write data until size is reached or an error occurred. | |
| int | writeExactly (const char *data, size_t size, std::chrono::nanoseconds timeout) |
| write data until size is reached, an error occurred or the given duration elapsed. | |
| int | writeExactly (const char *data, size_t size, TimePoint deadline) |
| write data until size is reached, an error occurred or the deadline expired. | |
| void | setMode (Mode mode) noexcept |
| set the mode of the underlying socket. | |
| int | setOption (Option opt, int val) noexcept |
| set an option for the underlying socket. | |
| int | handle () const noexcept |
| get the underlying socket handle. | |
| int | family () const noexcept |
| get the underlying socket address family. | |
| int | type () const noexcept |
| get the underlying socket type. | |
| int | protocol () const noexcept |
| get the underlying protocol. | |
| int | mtu () const noexcept |
| get the maximum transmission unit. | |
| Endpoint | localEndpoint () const noexcept |
| get the local endpoint. | |
| Endpoint | remoteEndpoint () const |
| get the remote endpoint. | |
Protected Member Functions | |
| int | handleTlsError (int result) noexcept |
| handle TLS error. | |
| void | infoCallback (int where, int ret) const noexcept |
| SSL state info callback. | |
| int | verifyCallback (int preverified, X509_STORE_CTX *context) noexcept |
| verify peer certificate. | |
| int | verifyCert (X509_STORE_CTX *context) const |
| verify certificate validity. | |
| bool | checkHostname (X509 *certificate) const noexcept |
| check certificate hostname against remote endpoint. | |
Static Protected Member Functions | |
| static void | infoWrapper (const SSL *ssl, int where, int ret) noexcept |
| c style info callback wrapper. | |
| static int | verifyWrapper (int preverified, X509_STORE_CTX *x509Ctx) noexcept |
| c style verify callback wrapper. | |
Protected Attributes | |
| UnderlyingSocket | _socket |
| verify certificate revocation using CRL. | |
| TlsContext | _ctx |
| TLS context. | |
| SslPtr | _ssl |
| TLS handle. | |
basic TLS/DTLS decorator.
| using join::BasicTls< Protocol >::Endpoint = typename Protocol::Endpoint |
| using join::BasicTls< Protocol >::Mode = typename UnderlyingSocket::Mode |
| using join::BasicTls< Protocol >::Option = typename UnderlyingSocket::Option |
| using join::BasicTls< Protocol >::State = typename UnderlyingSocket::State |
| using join::BasicTls< Protocol >::TimePoint = typename UnderlyingSocket::TimePoint |
| using join::BasicTls< Protocol >::UnderlyingSocket = typename Protocol::Transport::Socket |
|
inlineexplicitnoexcept |
create a TLS decorator with an internally created socket.
| ctx | TLS context. |
| mode | blocking mode. |
|
inlineexplicitnoexcept |
create a TLS decorator taking ownership of the given socket, without context.
| socket | underlying socket. |
|
inlinenoexcept |
create a TLS decorator taking ownership of the given socket.
| socket | underlying socket. |
| ctx | TLS context. |
|
delete |
copy constructor.
| other | other object to copy. |
|
inlinenoexcept |
move constructor.
| other | other object to move. |
|
virtualdefault |
destroy the instance.
|
inlinenoexcept |
assigns the specified endpoint to the underlying socket.
| ep | endpoint to assign to the underlying socket. |
|
inlinenoexcept |
assigns the specified device to the underlying socket.
| dev | device name. |
|
inlineprotectednoexcept |
check certificate hostname against remote endpoint.
| certificate | X509 certificate. |
|
inlinenoexcept |
close the socket handle.
|
inlinenoexcept |
connect the underlying socket to the remote endpoint.
| ep | endpoint to connect to. |
|
inlinenoexcept |
check if the underlying socket is connected.
|
inline |
set the TLS layer up without negotiating immediately.
|
inlinenoexcept |
disconnect the underlying socket from the remote endpoint.
|
inlinenoexcept |
check if the stream is encrypted.
|
inlinenoexcept |
get the underlying socket address family.
|
inlinenoexcept |
get the underlying socket handle.
|
inlineprotectednoexcept |
handle TLS error.
| result | result returned by a previous call of the openssl API. |
|
inline |
perform the TLS handshake.
|
inlineprotectednoexcept |
SSL state info callback.
| where | context flags. |
| ret | error condition. |
|
inlinestaticprotectednoexcept |
c style info callback wrapper.
| ssl | SSL object. |
| where | context flags. |
| ret | error condition. |
|
inlinenoexcept |
get the local endpoint.
|
inlinenoexcept |
get the maximum transmission unit.
|
inlinenoexcept |
open the underlying socket using the given protocol.
| protocol | protocol to use. |
|
inlinenoexcept |
check if the underlying socket is opened.
|
inlinenoexcept |
move assignment operator.
| other | other object to assign. |
|
delete |
copy assignment operator.
| other | other object to assign. |
|
inlinenoexcept |
get the underlying protocol.
|
inlinenoexcept |
read data from the TLS stream.
| buf | buffer to read into. |
| len | maximum number of bytes to read. |
|
inline |
read data until size is reached or an error occurred.
| data | buffer used to store the data received. |
| size | number of bytes to read. |
|
inline |
read data until size is reached, an error occurred or the given duration elapsed.
| data | buffer used to store the data received. |
| size | number of bytes to read. |
| timeout | maximum time granted to the whole read. |
|
inline |
read data until size is reached, an error occurred or the deadline expired.
| data | buffer used to store the data received. |
| size | number of bytes to read. |
| deadline | time point at which to give up, max to wait indefinitely. |
|
inline |
get the remote endpoint.
|
inlinenoexcept |
set the mode of the underlying socket.
| mode | socket mode. |
|
inlinenoexcept |
set an option for the underlying socket.
| opt | socket option. |
| val | option value. |
|
inlinenoexcept |
Perform the TLS shutdown.
|
inlinenoexcept |
get the underlying socket type.
|
inlineprotectednoexcept |
verify peer certificate.
| preverified | pre-verification status. |
| context | X509 store context. |
|
inlineprotected |
verify certificate validity.
| context | pointer to the complete context used for the certificate chain verification. |
|
inlinestaticprotectednoexcept |
c style verify callback wrapper.
| preverified | pre-verification status. |
| x509Ctx | X509 store context. |
|
inline |
block until TLS handshake is finished.
|
inline |
block until TLS handshake is finished, giving up after the given duration.
| timeout | maximum time granted to the whole handshake. |
|
inlinevirtual |
block until TLS handshake is finished, giving up at the given time point.
| deadline | time point at which to give up, max to wait indefinitely. |
Reimplemented in join::BasicTlsWrapper< Protocol >.
|
inlinenoexcept |
block until new data is available for reading.
|
inlinenoexcept |
block until new data is available for reading, giving up after the given duration.
| timeout | maximum time to wait. |
|
inlinenoexcept |
block until new data is available for reading, giving up at the given time point.
| deadline | time point at which to give up, max to wait indefinitely. |
|
inlinenoexcept |
block until at least one byte can be written on the socket.
|
inlinenoexcept |
block until at least one byte can be written on the socket, giving up after the given duration.
| timeout | maximum time to wait. |
|
inlinenoexcept |
block until at least one byte can be written, giving up at the given time point.
| deadline | time point at which to give up, max to wait indefinitely. |
|
inlinenoexcept |
block until TLS shutdown is finished.
|
inlinenoexcept |
block until TLS shutdown is finished, giving up after the given duration.
| timeout | maximum time granted to the whole shutdown. |
|
inlinenoexcept |
block until TLS shutdown is finished, giving up at the given time point.
| deadline | time point at which to give up, max to wait indefinitely. |
|
inlinenoexcept |
write data to the TLS stream.
| buf | buffer to write from. |
| len | number of bytes to write. |
|
inline |
write data until size is reached or an error occurred.
| data | data buffer to send. |
| size | number of bytes to write. |
|
inline |
write data until size is reached, an error occurred or the given duration elapsed.
| data | data buffer to send. |
| size | number of bytes to write. |
| timeout | maximum time granted to the whole write. |
|
inline |
write data until size is reached, an error occurred or the deadline expired.
| data | data buffer to send. |
| size | number of bytes to write. |
| deadline | time point at which to give up, max to wait indefinitely. |
|
protected |
TLS context.
|
protected |
verify certificate revocation using CRL.
| context | pointer to the complete context used for the certificate chain verification. |
verify certificate revocation using OCSP.
| context | pointer to the complete context used for the certificate chain verification. |
|
protected |
TLS handle.