95 const br_x509_trust_anchor *trust_anchors,
96 const size_t trust_anchors_num,
98 const size_t max_sessions = 1,
144 int connect(IPAddress ip, uint16_t port)
override;
182 int connect(
const char *host, uint16_t port)
override;
207 size_t write(
const uint8_t *buf,
size_t size)
override;
252 int read(uint8_t *buf,
size_t size)
override;
257 int read()
override { uint8_t read_val;
return read(&read_val, 1) > 0 ? read_val : -1; };
276 void flush()
override;
286 void stop()
override;
374 Client& get_arduino_client() {
return m_client; }
375 const Client& get_arduino_client()
const {
return m_client; }
378 bool m_soft_connected(
const char* func_name);
380 int m_start_ssl(
const char* host =
nullptr,
SSLSession* ssl_ses =
nullptr);
382 int m_run_until(
const unsigned target);
384 unsigned m_update_engine();
386 int m_get_session_index(
const char* host)
const;
389 void m_print_prefix(
const char* func_name,
const DebugLevel level)
const;
392 void m_print_ssl_error(
const int ssl_error,
const DebugLevel level)
const;
395 void m_print_br_error(
const unsigned br_error_code,
const DebugLevel level)
const;
399 void m_print(
const T str,
const char* func_name,
const DebugLevel level)
const {
401 if (level > m_debug || !Serial)
return;
403 m_print_prefix(func_name, level);
410 void m_info(
const T str,
const char* func_name)
const { m_print(str, func_name,
SSL_INFO); }
413 void m_warn(
const T str,
const char* func_name)
const { m_print(str, func_name,
SSL_WARN); }
416 void m_error(
const T str,
const char* func_name)
const { m_print(str, func_name,
SSL_ERROR); }
424 std::vector<SSLSession> m_sessions;
426 const size_t m_max_sessions;
428 const int m_analog_pin;
434 unsigned int m_timeout;
436 br_ssl_client_context m_sslctx;
437 br_x509_minimal_context m_x509ctx;
451 unsigned char m_iobuf[2048];
uint8_t connected() override
Check if the device is connected.
Definition: SSLClient.cpp:220
Definition: SSLClient.h:57
This class stores values which allow SSLClient to save and resume SSL sessions.
Definition: SSLSession.h:51
void setTimeout(unsigned int t)
Set the timeout when waiting for an SSL response.
Definition: SSLClient.h:364
Definition: SSLClient.h:47
Definition: SSLClient.h:74
Definition: SSLClient.h:53
SSLClient(Client &client, const br_x509_trust_anchor *trust_anchors, const size_t trust_anchors_num, const int analog_pin, const size_t max_sessions=1, const DebugLevel debug=SSL_WARN)
Initialize SSLClient with all of the prerequisites needed.
Definition: SSLClient.cpp:24
void flush() override
Force writing the buffered bytes from SSLClient::write to the network.
Definition: SSLClient.cpp:187
SSLSession * getSession(const char *host)
Gets a session reference corresponding to a host and IP, or a reference to a empty session if none ex...
Definition: SSLClient.cpp:251
int available() override
Returns the number of bytes available to read from the data that has been received and decrypted.
Definition: SSLClient.cpp:139
The main SSLClient class. Check out README.md for more info.
Definition: SSLClient.h:34
Definition: SSLClient.h:72
void stop() override
Close the connection.
Definition: SSLClient.cpp:193
Definition: SSLClient.h:70
int connect(IPAddress ip, uint16_t port) override
Connect over SSL to a host specified by an IP address.
Definition: SSLClient.cpp:51
size_t write(const uint8_t *buf, size_t size) override
Write some bytes to the SSL connection.
Definition: SSLClient.cpp:96
int read() override
Read a single byte, or -1 if none is available.
Definition: SSLClient.h:257
void setMutualAuthParams(const SSLClientParameters ¶ms)
Add a client certificate and enable support for mutual auth.
Definition: SSLClient.cpp:275
Error
Static constants defining the possible errors encountered.
Definition: SSLClient.h:44
Definition: SSLClient.h:51
DebugLevel
Level of verbosity used in logging for SSLClient.
Definition: SSLClient.h:66
size_t getSessionCount() const
Get the maximum number of SSL sessions that can be stored at once.
Definition: SSLClient.h:348
int peek() override
View the first byte of the buffer, without removing it from the SSLClient Buffer.
Definition: SSLClient.cpp:175
Definition: SSLClient.h:49
size_t write(uint8_t b) override
Definition: SSLClient.h:209
Client & getClient()
Returns a reference to the client object stored in this class. Take care not to break it.
Definition: SSLClient.h:358
void removeSession(const char *host)
Clear the session corresponding to a host and IP.
Definition: SSLClient.cpp:264
unsigned int getTimeout() const
Get the timeout when waiting for an SSL response.
Definition: SSLClient.h:370
This class stores data required for SSLClient to use mutual authentication.
Definition: SSLClientParameters.h:52
Definition: SSLClient.h:68
Definition: SSLClient.h:45
Definition: SSLClient.h:55