Go to the documentation of this file.
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;
void setTimeout(unsigned int t)
Set the timeout when waiting for an SSL response.
Definition: SSLClient.h:366
@ SSL_BR_CONNECT_FAIL
Definition: SSLClient.h:49
The main SSLClient class. Check out README.md for more info.
Definition: SSLClient.h:34
void stop() override
Close the connection.
Definition: SSLClient.cpp:196
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
int available() override
Returns the number of bytes available to read from the data that has been received and decrypted.
Definition: SSLClient.cpp:134
size_t write(uint8_t b) override
Definition: SSLClient.h:211
@ SSL_NONE
Definition: SSLClient.h:68
uint8_t connected() override
Check if the device is connected.
Definition: SSLClient.cpp:223
unsigned int getTimeout() const
Get the timeout when waiting for an SSL response.
Definition: SSLClient.h:372
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
@ SSL_OUT_OF_MEMORY
Definition: SSLClient.h:57
@ SSL_OK
Definition: SSLClient.h:45
@ SSL_INTERNAL_ERROR
Definition: SSLClient.h:55
Client & getClient()
Returns a reference to the client object stored in this class. Take care not to break it.
Definition: SSLClient.h:360
This class stores values which allow SSLClient to save and resume SSL sessions.
Definition: SSLSession.h:51
Error
Static constants defining the possible errors encountered.
Definition: SSLClient.h:44
@ SSL_CLIENT_CONNECT_FAIL
Definition: SSLClient.h:47
@ SSL_DUMP
Definition: SSLClient.h:76
void removeSession(const char *host)
Clear the session corresponding to a host and IP.
Definition: SSLClient.cpp:267
This class stores data required for SSLClient to use mutual authentication.
Definition: SSLClientParameters.h:52
size_t getSessionCount() const
Get the maximum number of SSL sessions that can be stored at once.
Definition: SSLClient.h:350
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:254
size_t write(const uint8_t *buf, size_t size) override
Write some bytes to the SSL connection.
Definition: SSLClient.cpp:93
void setMutualAuthParams(const SSLClientParameters ¶ms)
Add a client certificate and enable support for mutual auth.
Definition: SSLClient.cpp:278
void setVerificationTime(uint32_t days, uint32_t seconds)
Change the time used during x509 verification to a different value.
Definition: SSLClient.cpp:300
@ SSL_INFO
Definition: SSLClient.h:74
@ SSL_WARN
Definition: SSLClient.h:72
@ SSL_BR_WRITE_ERROR
Definition: SSLClient.h:53
@ SSL_CLIENT_WRTIE_ERROR
Definition: SSLClient.h:51
void flush() override
Force writing the buffered bytes from SSLClient::write to the network.
Definition: SSLClient.cpp:182
int connect(IPAddress ip, uint16_t port) override
Connect over SSL to a host specified by an IP address.
Definition: SSLClient.cpp:52
@ SSL_ERROR
Definition: SSLClient.h:70
int peek() override
View the first byte of the buffer, without removing it from the SSLClient Buffer.
Definition: SSLClient.cpp:170