Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit e3ed6d8

Browse files
authored
v1.4.5 to Sync with SSLClient v1.6.11
### Releases v1.4.5 1. Sync with [SSLClient v1.6.11](https://github.com/OPEnSLab-OSU/SSLClient/releases/tag/v1.6.11). Check [Pull in OPEnSLab-OSU's SSLClient v1.6.11 #17](khoih-prog/EthernetWebServer_SSL#17) 2. Add example [AWS_IoT](examples/AWS_IoT)
1 parent b3dd24f commit e3ed6d8

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/SSLClient/SSLClient.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,20 @@ class EthernetSSLClient : public Client
396396
{
397397
return m_timeout;
398398
}
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);
399413

400414
private:
401415
/** @brief Returns an instance of m_client that is polymorphic and can be used by EthernetSSLClient */

src/SSLClient/SSLClient_Impl.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,24 @@ size_t EthernetSSLClient::write(const uint8_t *buf, size_t size)
121121
// check if the socket is still open and such
122122
if (!m_soft_connected(func_name) || !buf || !size)
123123
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+
}
124131

125132
// add to the bearssl io buffer, simply appending whatever we want to write
126133
size_t alen;
127134
unsigned char *br_buf = br_ssl_engine_sendapp_buf(&m_sslctx.eng, &alen);
128135
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+
}
129142

130143
// while there are still elements to write
131144
while (cur_idx < size)
@@ -389,6 +402,12 @@ void EthernetSSLClient::setMutualAuthParams(const SSLClientParameters& params)
389402
}
390403
}
391404

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+
392411
bool EthernetSSLClient::m_soft_connected(const char* func_name)
393412
{
394413
// check if the socket is still open and such

0 commit comments

Comments
 (0)