Handles all SSL activity for a TCP connection. More...

#include <Session.h>

Collaboration diagram for Ssl::Session:

Public Types

using InitDelegate = Delegate< void(Session &session)>
 

Public Member Functions

 ~Session ()
 
const SessionIdgetSessionId () const
 If available, return the current SSL Session ID. More...
 
bool onAccept (TcpConnection *client, tcp_pcb *tcp)
 Called when a client connection is made via server TCP socket. More...
 
void setConnection (Connection *connection)
 Called by TcpConnection to set the established SSL connection. More...
 
ConnectiongetConnection ()
 Get the currently active SSL connection object. More...
 
bool onConnect (tcp_pcb *tcp)
 Handle connection event. More...
 
bool isConnected () const
 Determine if an SSL connection has been fully established. More...
 
void close ()
 End the session. More...
 
int read (InputBuffer &input, uint8_t *&output)
 Read data from SSL connection. More...
 
int write (const uint8_t *data, size_t length)
 Write data to SSL connection. More...
 
bool validateCertificate ()
 Called by SSL adapter when certificate validation is required. More...
 
void handshakeComplete (bool success)
 Called by SSL adapter when handshake has been completed. More...
 
size_t printTo (Print &p) const
 For debugging. More...
 

Public Attributes

String hostName
 Used for SNI https://en.wikipedia.org/wiki/Server_Name_Indication. More...
 
KeyCertPair keyCert
 Required for server, optional for client. More...
 
Options options
 Various connection options. More...
 
MaxBufferSize maxBufferSize = MaxBufferSize::Default
 Controls SSL RAM usage. More...
 
const CipherSuites::ArraycipherSuites = &CipherSuites::basic
 
int cacheSize = 10
 Set session caching. More...
 
ValidatorList validators
 List of certificate validators used by Client. More...
 

Detailed Description

Handles all SSL activity for a TCP connection.

A session is created for every TCP connection where useSsl is specified. It is then passed to any registered session initialisation callbacks for customisation.

Member Typedef Documentation

◆ InitDelegate

using Ssl::Session::InitDelegate = Delegate<void(Session& session)>

Constructor & Destructor Documentation

◆ ~Session()

Ssl::Session::~Session ( )
inline

Member Function Documentation

◆ close()

void Ssl::Session::close ( )

End the session.

SSL typically sends a closing handshake at this point

◆ getConnection()

Connection* Ssl::Session::getConnection ( )
inline

Get the currently active SSL connection object.

Return values
Connection*

◆ getSessionId()

const SessionId* Ssl::Session::getSessionId ( ) const
inline

If available, return the current SSL Session ID.

Return values
SessionId*If connection hasn't been established, may return Null

◆ handshakeComplete()

void Ssl::Session::handshakeComplete ( bool  success)

Called by SSL adapter when handshake has been completed.

Parameters
successIndicates if handshake was successful
Note
SSL Internal method

◆ isConnected()

bool Ssl::Session::isConnected ( ) const
inline

Determine if an SSL connection has been fully established.

Return values
boolConnection state

◆ onAccept()

bool Ssl::Session::onAccept ( TcpConnection client,
tcp_pcb *  tcp 
)

Called when a client connection is made via server TCP socket.

Parameters
clientThe client TCP socket
tcpThe low-level TCP connection to use for reading and writing
Return values
booltrue if the connection may proceed, false to abort

◆ onConnect()

bool Ssl::Session::onConnect ( tcp_pcb *  tcp)

Handle connection event.

Parameters
tcp
Return values
booltrue on success, false to abort the connection

◆ printTo()

size_t Ssl::Session::printTo ( Print p) const

For debugging.

◆ read()

int Ssl::Session::read ( InputBuffer input,
uint8_t *&  output 
)

Read data from SSL connection.

Parameters
inputSource encrypted data
outputPoints to decrypted content
Return values
intSize of decrypted data returned, or negative on error

◆ setConnection()

void Ssl::Session::setConnection ( Connection connection)
inline

Called by TcpConnection to set the established SSL connection.

Parameters
connectionThe server connection

◆ validateCertificate()

bool Ssl::Session::validateCertificate ( )

Called by SSL adapter when certificate validation is required.

Return values
booltrue if validation is success, false to abort connection
Note
SSL Internal method

◆ write()

int Ssl::Session::write ( const uint8_t data,
size_t  length 
)

Write data to SSL connection.

Parameters
data
length
Return values
intQuantity of bytes actually written, or tcp error code

Member Data Documentation

◆ cacheSize

int Ssl::Session::cacheSize = 10

Set session caching.

Server: Number of cached client sessions. Suggested value: 10.

Client: Number of cached session ids. Suggested value: 1.

◆ cipherSuites

const CipherSuites::Array* Ssl::Session::cipherSuites = &CipherSuites::basic

Configure supported cipher suites. Default is basic.

◆ hostName

String Ssl::Session::hostName

◆ keyCert

KeyCertPair Ssl::Session::keyCert

Required for server, optional for client.

◆ maxBufferSize

MaxBufferSize Ssl::Session::maxBufferSize = MaxBufferSize::Default

Controls SSL RAM usage.

◆ options

Options Ssl::Session::options

Various connection options.

◆ validators

ValidatorList Ssl::Session::validators

List of certificate validators used by Client.


The documentation for this class was generated from the following file: