96 const br_x509_trust_anchor *trust_anchors,
97 const size_t trust_anchors_num,
99 const size_t max_sessions = 1,
145 int connect(IPAddress ip, uint16_t port)
override;
183 int connect(
const char *host, uint16_t port)
override;
208 size_t write(
const uint8_t *buf,
size_t size)
override;
253 int read(uint8_t *buf,
size_t size)
override;
258 int read()
override { uint8_t read_val;
return read(&read_val, 1) > 0 ? read_val : -1; };
277 void flush()
override;
287 void stop()
override;
375 Client& get_arduino_client() {
return m_client; }
376 const Client& get_arduino_client()
const {
return m_client; }
379 bool m_soft_connected(
const char* func_name);
381 int m_start_ssl(
const char* host =
nullptr,
SSLSession* ssl_ses =
nullptr);
383 int m_run_until(
const unsigned target);
385 unsigned m_update_engine();
387 int m_get_session_index(
const char* host)
const;
390 void m_print_prefix(
const char* func_name,
const DebugLevel level)
const;
393 void m_print_ssl_error(
const int ssl_error,
const DebugLevel level)
const;
396 void m_print_br_error(
const unsigned br_error_code,
const DebugLevel level)
const;
400 void m_print(
const T str,
const char* func_name,
const DebugLevel level)
const {
402 if (level > m_debug || !Serial)
return;
404 m_print_prefix(func_name, level);
411 void m_info(
const T str,
const char* func_name)
const { m_print(str, func_name,
SSL_INFO); }
414 void m_warn(
const T str,
const char* func_name)
const { m_print(str, func_name,
SSL_WARN); }
417 void m_error(
const T str,
const char* func_name)
const { m_print(str, func_name,
SSL_ERROR); }
425 std::vector<SSLSession> m_sessions;
427 const size_t m_max_sessions;
429 const int m_analog_pin;
435 unsigned int m_timeout;
437 br_ssl_client_context m_sslctx;
438 br_x509_minimal_context m_x509ctx;
452 unsigned char m_iobuf[2048];
uint8_t connected() override
Check if the device is connected.
Definition: SSLClient.cpp:251
Definition: SSLClient.h:58
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:365
Definition: SSLClient.h:48
Definition: SSLClient.h:75
Definition: SSLClient.h:54
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:55
void flush() override
Force writing the buffered bytes from SSLClient::write to the network.
Definition: SSLClient.cpp:218
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:282
This struct stores data required for SSLClient to use mutual authentication.
Definition: SSLClientParameters.h:52
void setMutualAuthParams(const SSLClientParameters *params)
Add a client certificate and enable support for mutual auth.
Definition: SSLClient.cpp:306
int available() override
Returns the number of bytes available to read from the data that has been received and decrypted.
Definition: SSLClient.cpp:170
The main SSLClient class. Check out README.md for more info.
Definition: SSLClient.h:35
Definition: SSLClient.h:73
void stop() override
Close the connection.
Definition: SSLClient.cpp:224
Definition: SSLClient.h:71
int connect(IPAddress ip, uint16_t port) override
Connect over SSL to a host specified by an IP address.
Definition: SSLClient.cpp:82
size_t write(const uint8_t *buf, size_t size) override
Write some bytes to the SSL connection.
Definition: SSLClient.cpp:127
int read() override
Read a single byte, or -1 if none is available.
Definition: SSLClient.h:258
Error
Static constants defining the possible errors encountered.
Definition: SSLClient.h:45
Definition: SSLClient.h:52
DebugLevel
Level of verbosity used in logging for SSLClient.
Definition: SSLClient.h:67
size_t getSessionCount() const
Get the maximum number of SSL sessions that can be stored at once.
Definition: SSLClient.h:349
int peek() override
View the first byte of the buffer, without removing it from the SSLClient Buffer.
Definition: SSLClient.cpp:206
Definition: SSLClient.h:50
size_t write(uint8_t b) override
Definition: SSLClient.h:210
Client & getClient()
Returns a reference to the client object stored in this class. Take care not to break it.
Definition: SSLClient.h:359
void removeSession(const char *host)
Clear the session corresponding to a host and IP.
Definition: SSLClient.cpp:295
unsigned int getTimeout() const
Get the timeout when waiting for an SSL response.
Definition: SSLClient.h:371
Definition: SSLClient.h:69
Definition: SSLClient.h:46
Definition: SSLClient.h:56