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;
363 Client& get_arduino_client() {
return m_client; }
364 const Client& get_arduino_client()
const {
return m_client; }
367 bool m_soft_connected(
const char* func_name);
369 int m_start_ssl(
const char* host =
nullptr,
SSLSession* ssl_ses =
nullptr);
371 int m_run_until(
const unsigned target);
373 unsigned m_update_engine();
375 int m_get_session_index(
const char* host)
const;
378 void m_print_prefix(
const char* func_name,
const DebugLevel level)
const;
381 void m_print_ssl_error(
const int ssl_error,
const DebugLevel level)
const;
384 void m_print_br_error(
const unsigned br_error_code,
const DebugLevel level)
const;
388 void m_print(
const T str,
const char* func_name,
const DebugLevel level)
const {
390 if (level > m_debug || !Serial)
return;
392 m_print_prefix(func_name, level);
399 void m_info(
const T str,
const char* func_name)
const { m_print(str, func_name,
SSL_INFO); }
402 void m_warn(
const T str,
const char* func_name)
const { m_print(str, func_name,
SSL_WARN); }
405 void m_error(
const T str,
const char* func_name)
const { m_print(str, func_name,
SSL_ERROR); }
413 std::vector<SSLSession> m_sessions;
415 const size_t m_max_sessions;
417 const int m_analog_pin;
423 br_ssl_client_context m_sslctx;
424 br_x509_minimal_context m_x509ctx;
438 unsigned char m_iobuf[2048];
uint8_t connected() override
Check if the device is connected.
Definition: SSLClient.cpp:255
Definition: SSLClient.h:58
This class stores values which allow SSLClient to save and resume SSL sessions.
Definition: SSLSession.h:51
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:222
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:286
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:310
int available() override
Returns the number of bytes available to read from the data that has been received and decrypted.
Definition: SSLClient.cpp:174
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:228
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:131
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:210
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:299
Definition: SSLClient.h:69
Definition: SSLClient.h:46
Definition: SSLClient.h:56