3434
3535#include " BearSSLClient.h"
3636
37- bool BearSSLClient::_sslio_closing = false ;
38-
3937extern " C" void aiotc_client_profile_init (br_ssl_client_context *cc, br_x509_minimal_context *xc, const br_x509_trust_anchor *trust_anchors, size_t trust_anchors_num);
4038
4139BearSSLClient::BearSSLClient () :
4240 _noSNI(false ),
43- _get_time_func(nullptr )
41+ _get_time_func(nullptr ),
42+ _sslio_closing(false )
4443{
4544 _ecKey.curve = 0 ;
4645 _ecKey.x = NULL ;
@@ -172,7 +171,7 @@ void BearSSLClient::stop()
172171{
173172 if (_client->connected ()) {
174173 if ((br_ssl_engine_current_state (&_sc.eng ) & BR_SSL_CLOSED) == 0 ) {
175- BearSSLClient:: _sslio_closing = true ;
174+ _sslio_closing = true ;
176175 br_sslio_close (&_ioc);
177176 }
178177
@@ -314,7 +313,7 @@ int BearSSLClient::connectSSL(const char* host)
314313 br_x509_minimal_set_time (&_xc, days, sec);
315314
316315 // use our own socket I/O operations
317- br_sslio_init (&_ioc, &_sc.eng , BearSSLClient::clientRead, _client , BearSSLClient::clientWrite, _client );
316+ br_sslio_init (&_ioc, &_sc.eng , BearSSLClient::clientRead, this , BearSSLClient::clientWrite, this );
318317
319318 br_sslio_flush (&_ioc);
320319
@@ -335,12 +334,13 @@ int BearSSLClient::connectSSL(const char* host)
335334
336335int BearSSLClient::clientRead (void *ctx, unsigned char *buf, size_t len)
337336{
338- if (BearSSLClient::_sslio_closing) {
337+ BearSSLClient* bc = (BearSSLClient*)ctx;
338+ Client* c = bc->_client ;
339+
340+ if (bc->_sslio_closing ) {
339341 return -1 ;
340342 }
341343
342- Client* c = (Client*)ctx;
343-
344344 if (!c->connected ()) {
345345 return -1 ;
346346 }
@@ -370,12 +370,13 @@ int BearSSLClient::clientRead(void *ctx, unsigned char *buf, size_t len)
370370
371371int BearSSLClient::clientWrite (void *ctx, const unsigned char *buf, size_t len)
372372{
373- if (BearSSLClient::_sslio_closing) {
373+ BearSSLClient* bc = (BearSSLClient*)ctx;
374+ Client* c = bc->_client ;
375+
376+ if (bc->_sslio_closing ) {
374377 return -1 ;
375378 }
376379
377- Client* c = (Client*)ctx;
378-
379380#ifdef DEBUGSERIAL
380381 DEBUGSERIAL.print (" BearSSLClient::clientWrite - " );
381382 DEBUGSERIAL.print (len);
0 commit comments