35 template <
class C,
size_t SessionCache = 1>
51 static_assert(SessionCache > 0 && SessionCache < 255,
"There can be no less than one and no more than 255 sessions in the cache!");
52 static_assert(SessionCache <= 3,
"You need to decrease the size of m_iobuf in order to have more than 3 sessions at once, otherwise memory issues will occur.");
73 const br_x509_trust_anchor *trust_anchors,
74 const size_t trust_anchors_num,
77 :
SSLClientImpl(trust_anchors, trust_anchors_num, analog_pin, debug)
83 setTimeout(30 * 1000);
194 size_t write(
const uint8_t *buf,
size_t size)
override {
return write_impl(buf, size); }
220 int read()
override { uint8_t read_val;
return read(&read_val, 1) > 0 ? read_val : -1; };
242 int read(uint8_t *buf,
size_t size)
override {
return read_impl(buf, size); }
339 bool operator==(
const bool value) {
return bool() == value; }
341 bool operator!=(
const bool value) {
return bool() != value; }
347 uint16_t
localPort()
override {
return m_client.localPort(); }
349 IPAddress
remoteIP()
override {
return m_client.remoteIP(); }
351 uint16_t
remotePort()
override {
return m_client.remotePort(); }
void setMutualAuthParams(const SSLClientParameters *params)
Add a client certificate and enable support for mutual auth.
Definition: SSLClient.h:297
+
size_t write_impl(const uint8_t *buf, size_t size)
Definition: SSLClientImpl.cpp:130
+
const SSLSession * get_session_array() const override
Definition: SSLClient.h:362
+
IPAddress remoteIP() override
Returns the remote IP, if C::remoteIP exists.
Definition: SSLClient.h:349
+
size_t write(uint8_t b) override
Definition: SSLClient.h:170
Definition: SSLClientImpl.h:66
-
SSLSession & get_session_impl(const char *host, const IPAddress &addr)
Definition: SSLClientImpl.cpp:305
+
SSLSession & get_session_impl(const char *host, const IPAddress &addr)
Definition: SSLClientImpl.cpp:286
This class stores values which allow SSLClient to save and resume SSL sessions.
Definition: SSLSession.h:52
-
SSLClient(const C &client, const br_x509_trust_anchor *trust_anchors, const size_t trust_anchors_num, const int analog_pin, const DebugLevel debug, const SSLClientParameters *mutual_auth_params)
Definition: SSLClient.h:89
-
bool operator!=(const C &rhs)
Returns whether or not two SSLClient objects do not have the same underlying client object.
Definition: SSLClient.h:356
-
int available() override
Returns the number of bytes available to read from the data that has been received and decrypted.
Definition: SSLClient.h:232
-
C & getClient()
Returns a reference to the client object stored in this class. Take care not to break it.
Definition: SSLClient.h:365
-
int peek_impl()
Definition: SSLClientImpl.cpp:226
+
bool operator!=(const C &rhs)
Returns whether or not two SSLClient objects do not have the same underlying client object.
Definition: SSLClient.h:345
+
int available() override
Returns the number of bytes available to read from the data that has been received and decrypted.
Definition: SSLClient.h:214
+
C & getClient()
Returns a reference to the client object stored in this class. Take care not to break it.
Definition: SSLClient.h:354
+
int peek_impl()
Definition: SSLClientImpl.cpp:209
This struct stores data required for SSLClient to use mutual authentication.
Definition: SSLClientParameters.h:52
-
void flush() override
Force writing the buffered bytes from SSLClient::write to the network.
Definition: SSLClient.h:279
-
The main SSLClient class. Check out README.md for more info.
Definition: SSLClient.h:35
-
bool operator!=(const bool value)
Definition: SSLClient.h:352
-
void stop() override
Close the connection.
Definition: SSLClient.h:289
-
size_t write(const uint8_t *buf, size_t size) override
Write some bytes to the SSL connection.
Definition: SSLClient.h:212
-
SSLClient(const C &client, const br_x509_trust_anchor *trust_anchors, const size_t trust_anchors_num, const int analog_pin, const DebugLevel debug=SSL_WARN)
Initialize SSLClient with all of the prerequisites needed.
Definition: SSLClient.h:71
-
int peek() override
View the first byte of the buffer, without removing it from the SSLClient Buffer.
Definition: SSLClient.h:270
-
int available_impl()
Definition: SSLClientImpl.cpp:190
-
bool operator==(const C &rhs)
Returns whether or not two SSLClient objects have the same underlying client object.
Definition: SSLClient.h:354
-
int read_impl(uint8_t *buf, size_t size)
Definition: SSLClientImpl.cpp:211
-
SSLSession * get_session_array() override
Returns an instance of the session array that is on the stack.
Definition: SSLClient.h:372
-
void remove_session_impl(const char *host, const IPAddress &addr)
Definition: SSLClientImpl.cpp:324
-
Client & get_arduino_client() override
Returns an instance of m_client that is polymorphic and can be used by SSLClientImpl.
Definition: SSLClient.h:369
-
uint16_t localPort() override
Returns the local port, if C::localPort exists.
Definition: SSLClient.h:358
+
void flush() override
Force writing the buffered bytes from SSLClient::write to the network.
Definition: SSLClient.h:261
+
The main SSLClient class. Check out README.md for more info.
Definition: SSLClient.h:36
+
bool operator!=(const bool value)
Definition: SSLClient.h:341
+
void stop() override
Close the connection.
Definition: SSLClient.h:271
+
size_t write(const uint8_t *buf, size_t size) override
Write some bytes to the SSL connection.
Definition: SSLClient.h:194
+
SSLClient(const C &client, const br_x509_trust_anchor *trust_anchors, const size_t trust_anchors_num, const int analog_pin, const DebugLevel debug=SSL_WARN)
Initialize SSLClient with all of the prerequisites needed.
Definition: SSLClient.h:72
+
int peek() override
View the first byte of the buffer, without removing it from the SSLClient Buffer.
Definition: SSLClient.h:252
+
int available_impl()
Definition: SSLClientImpl.cpp:173
+
bool operator==(const C &rhs)
Returns whether or not two SSLClient objects have the same underlying client object.
Definition: SSLClient.h:343
+
int read_impl(uint8_t *buf, size_t size)
Definition: SSLClientImpl.cpp:194
+
SSLSession * get_session_array() override
Returns an instance of the session array that is on the stack.
Definition: SSLClient.h:361
+
void remove_session_impl(const char *host, const IPAddress &addr)
Definition: SSLClientImpl.cpp:305
+
Client & get_arduino_client() override
Returns an instance of m_client that is polymorphic and can be used by SSLClientImpl.
Definition: SSLClient.h:358
+
uint16_t localPort() override
Returns the local port, if C::localPort exists.
Definition: SSLClient.h:347
-
int read() override
Read a single byte, or -1 if none is available.
Definition: SSLClient.h:238
+
void set_mutual_impl(const SSLClientParameters *params)
Definition: SSLClientImpl.cpp:316
+
int read() override
Read a single byte, or -1 if none is available.
Definition: SSLClient.h:220
-
uint8_t connected() override
Check if the device is connected.
Definition: SSLClient.h:304
+
uint8_t connected() override
Check if the device is connected.
Definition: SSLClient.h:286
-
const Client & get_arduino_client() const override
Definition: SSLClient.h:370
-
int connect(const char *host, uint16_t port) override
Connect over SSL to a host specified by a hostname.
Definition: SSLClient.h:185
-
bool operator==(const bool value)
Definition: SSLClient.h:350
-
uint16_t remotePort() override
Returns the remote port, if C::remotePort exists. Else return 0.
Definition: SSLClient.h:362
-
int connect_impl(IPAddress ip, uint16_t port)
Definition: SSLClientImpl.cpp:90
-
size_t getSessionCount() const override
Get the maximum number of SSL sessions that can be stored at once.
Definition: SSLClient.h:341
-
void stop_impl()
Definition: SSLClientImpl.cpp:246
-
void flush_impl()
Definition: SSLClientImpl.cpp:238
+
const Client & get_arduino_client() const override
Definition: SSLClient.h:359
+
int connect(const char *host, uint16_t port) override
Connect over SSL to a host specified by a hostname.
Definition: SSLClient.h:167
+
bool operator==(const bool value)
Definition: SSLClient.h:339
+
uint16_t remotePort() override
Returns the remote port, if C::remotePort exists. Else return 0.
Definition: SSLClient.h:351
+
int connect_impl(IPAddress ip, uint16_t port)
Definition: SSLClientImpl.cpp:73
+
size_t getSessionCount() const override
Get the maximum number of SSL sessions that can be stored at once.
Definition: SSLClient.h:330
+
void stop_impl()
Definition: SSLClientImpl.cpp:227
+
void flush_impl()
Definition: SSLClientImpl.cpp:221
+
Implementation code to be inherited by SSLClient.
Definition: SSLClientImpl.h:72
-
void removeSession(const char *host, const IPAddress &addr)
Clear the session corresponding to a host and IP.
Definition: SSLClient.h:334
-
uint8_t connected_impl()
Definition: SSLClientImpl.cpp:274
-
SSLSession & getSession(const char *host, const IPAddress &addr)
Gets a session reference corresponding to a host and IP, or a reference to a empty session if none ex...
Definition: SSLClient.h:324
+
void removeSession(const char *host, const IPAddress &addr)
Clear the session corresponding to a host and IP.
Definition: SSLClient.h:323
+
uint8_t connected_impl()
Definition: SSLClientImpl.cpp:255
+
SSLSession & getSession(const char *host, const IPAddress &addr)
Gets a session reference corresponding to a host and IP, or a reference to a empty session if none ex...
Definition: SSLClient.h:313
DebugLevel
Level of verbosity used in logging for SSLClient.
Definition: SSLClientImpl.h:60
-
int read(uint8_t *buf, size_t size) override
Read size bytes from the SSL client buffer, copying them into *buf, and return the number of bytes re...
Definition: SSLClient.h:260
-
int connect(IPAddress ip, uint16_t port) override
Connect over SSL to a host specified by an IP address.
Definition: SSLClient.h:147
+
int read(uint8_t *buf, size_t size) override
Read size bytes from the SSL client buffer, copying them into *buf, and return the number of bytes re...
Definition: SSLClient.h:242
+
int connect(IPAddress ip, uint16_t port) override
Connect over SSL to a host specified by an IP address.
Definition: SSLClient.h:129