This repository was archived by the owner on Jan 29, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -396,6 +396,20 @@ class EthernetSSLClient : public Client
396
396
{
397
397
return m_timeout;
398
398
}
399
+
400
+ /* *
401
+ @brief Change the time used during x509 verification to a different value.
402
+
403
+ This function directly calls br_x509_minimal_set_time to change the validation
404
+ time used by the minimal verification engine. You can use this function if the default value
405
+ of the compile time is causing issues. See https://bearssl.org/apidoc/bearssl__x509_8h.html#a7f3558b1999ce904084d578700b1002c
406
+ for more information what this function does and how to use it.
407
+
408
+ @param days Days are counted in a proleptic Gregorian calendar since January 1st, 0 AD.
409
+ @param seconds Seconds are counted since midnight, from 0 to 86400 (a count of 86400 is possible only if a leap second happened).
410
+ */
411
+
412
+ void setVerificationTime (uint32_t days, uint32_t seconds);
399
413
400
414
private:
401
415
/* * @brief Returns an instance of m_client that is polymorphic and can be used by EthernetSSLClient */
Original file line number Diff line number Diff line change @@ -121,11 +121,24 @@ size_t EthernetSSLClient::write(const uint8_t *buf, size_t size)
121
121
// check if the socket is still open and such
122
122
if (!m_soft_connected (func_name) || !buf || !size)
123
123
return 0 ;
124
+
125
+ // wait until bearssl is ready to send
126
+ if (m_run_until (BR_SSL_SENDAPP) < 0 )
127
+ {
128
+ m_error (" Failed while waiting for the engine to enter BR_SSL_SENDAPP" , func_name);
129
+ return 0 ;
130
+ }
124
131
125
132
// add to the bearssl io buffer, simply appending whatever we want to write
126
133
size_t alen;
127
134
unsigned char *br_buf = br_ssl_engine_sendapp_buf (&m_sslctx.eng , &alen);
128
135
size_t cur_idx = 0 ;
136
+
137
+ if (alen == 0 )
138
+ {
139
+ m_error (" BearSSL returned zero length buffer for sending, did an internal error occur?" , func_name);
140
+ return 0 ;
141
+ }
129
142
130
143
// while there are still elements to write
131
144
while (cur_idx < size)
@@ -389,6 +402,12 @@ void EthernetSSLClient::setMutualAuthParams(const SSLClientParameters& params)
389
402
}
390
403
}
391
404
405
+ /* see SSLClient.h */
406
+ void EthernetSSLClient::setVerificationTime (uint32_t days, uint32_t seconds)
407
+ {
408
+ br_x509_minimal_set_time (&m_x509ctx, days, seconds);
409
+ }
410
+
392
411
bool EthernetSSLClient::m_soft_connected (const char * func_name)
393
412
{
394
413
// check if the socket is still open and such
You can’t perform that action at this time.
0 commit comments