97 const br_x509_trust_anchor *trust_anchors,
98 const size_t trust_anchors_num,
100 const size_t max_sessions = 1,
146 int connect(IPAddress ip, uint16_t port)
override;
184 int connect(
const char *host, uint16_t port)
override;
209 size_t write(
const uint8_t *buf,
size_t size)
override;
254 int read(uint8_t *buf,
size_t size)
override;
259 int read()
override { uint8_t read_val;
return read(&read_val, 1) > 0 ? read_val : -1; };
278 void flush()
override;
288 void stop()
override;
389 Client& get_arduino_client() {
return m_client; }
390 const Client& get_arduino_client()
const {
return m_client; }
393 bool m_soft_connected(
const char* func_name);
395 int m_start_ssl(
const char* host =
nullptr,
SSLSession* ssl_ses =
nullptr);
397 int m_run_until(
const unsigned target);
399 unsigned m_update_engine();
401 int m_get_session_index(
const char* host)
const;
404 void m_print_prefix(
const char* func_name,
const DebugLevel level)
const;
407 void m_print_ssl_error(
const int ssl_error,
const DebugLevel level)
const;
410 void m_print_br_error(
const unsigned br_error_code,
const DebugLevel level)
const;
413 void m_print_br_state(
const unsigned br_state,
const DebugLevel level)
const;
417 void m_print(
const T str,
const char* func_name,
const DebugLevel level)
const {
419 if (level > m_debug || !Serial)
return;
421 m_print_prefix(func_name, level);
428 void m_info(
const T str,
const char* func_name)
const { m_print(str, func_name,
SSL_INFO); }
431 void m_warn(
const T str,
const char* func_name)
const { m_print(str, func_name,
SSL_WARN); }
434 void m_error(
const T str,
const char* func_name)
const { m_print(str, func_name,
SSL_ERROR); }
442 std::vector<SSLSession> m_sessions;
444 const size_t m_max_sessions;
446 const int m_analog_pin;
452 unsigned int m_timeout;
454 br_ssl_client_context m_sslctx;
455 br_x509_minimal_context m_x509ctx;
469 unsigned char m_iobuf[2048];
475 unsigned m_br_last_state;
The main SSLClient class. Check out README.md for more info.
Definition: SSLClient.h:34
size_t write(const uint8_t *buf, size_t size) override
Write some bytes to the SSL connection.
Definition: SSLClient.cpp:93
int peek() override
View the first byte of the buffer, without removing it from the SSLClient Buffer.
Definition: SSLClient.cpp:179
int available() override
Returns the number of bytes available to read from the data that has been received and decrypted.
Definition: SSLClient.cpp:143
unsigned int getTimeout() const
Get the timeout when waiting for an SSL response.
Definition: SSLClient.h:372
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:263
Error
Static constants defining the possible errors encountered.
Definition: SSLClient.h:44
@ SSL_OUT_OF_MEMORY
Definition: SSLClient.h:57
@ SSL_OK
Definition: SSLClient.h:45
@ SSL_BR_WRITE_ERROR
Definition: SSLClient.h:53
@ SSL_BR_CONNECT_FAIL
Definition: SSLClient.h:49
@ SSL_CLIENT_CONNECT_FAIL
Definition: SSLClient.h:47
@ SSL_CLIENT_WRTIE_ERROR
Definition: SSLClient.h:51
@ SSL_INTERNAL_ERROR
Definition: SSLClient.h:55
uint8_t connected() override
Check if the device is connected.
Definition: SSLClient.cpp:232
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
size_t write(uint8_t b) override
Definition: SSLClient.h:211
void setTimeout(unsigned int t)
Set the timeout when waiting for an SSL response.
Definition: SSLClient.h:366
Client & getClient()
Returns a reference to the client object stored in this class. Take care not to break it.
Definition: SSLClient.h:360
void flush() override
Force writing the buffered bytes from SSLClient::write to the network.
Definition: SSLClient.cpp:191
void setVerificationTime(uint32_t days, uint32_t seconds)
Change the time used during x509 verification to a different value.
Definition: SSLClient.cpp:309
int connect(IPAddress ip, uint16_t port) override
Connect over SSL to a host specified by an IP address.
Definition: SSLClient.cpp:52
void removeSession(const char *host)
Clear the session corresponding to a host and IP.
Definition: SSLClient.cpp:276
void stop() override
Close the connection.
Definition: SSLClient.cpp:205
size_t getSessionCount() const
Get the maximum number of SSL sessions that can be stored at once.
Definition: SSLClient.h:350
void setMutualAuthParams(const SSLClientParameters ¶ms)
Add a client certificate and enable support for mutual auth.
Definition: SSLClient.cpp:287
int read() override
Read a single byte, or -1 if none is available.
Definition: SSLClient.h:259
DebugLevel
Level of verbosity used in logging for SSLClient.
Definition: SSLClient.h:66
@ SSL_ERROR
Definition: SSLClient.h:70
@ SSL_NONE
Definition: SSLClient.h:68
@ SSL_WARN
Definition: SSLClient.h:72
@ SSL_INFO
Definition: SSLClient.h:74
@ SSL_DUMP
Definition: SSLClient.h:76
This class stores data required for SSLClient to use mutual authentication.
Definition: SSLClientParameters.h:52
This class stores values which allow SSLClient to save and resume SSL sessions.
Definition: SSLSession.h:51