34
34
35
35
#include " BearSSLClient.h"
36
36
37
- bool BearSSLClient::_sslio_closing = false ;
38
-
39
37
extern " 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);
40
38
41
39
BearSSLClient::BearSSLClient () :
42
40
_noSNI(false ),
43
- _get_time_func(nullptr )
41
+ _get_time_func(nullptr ),
42
+ _sslio_closing(false )
44
43
{
45
44
_ecKey.curve = 0 ;
46
45
_ecKey.x = NULL ;
@@ -172,7 +171,7 @@ void BearSSLClient::stop()
172
171
{
173
172
if (_client->connected ()) {
174
173
if ((br_ssl_engine_current_state (&_sc.eng ) & BR_SSL_CLOSED) == 0 ) {
175
- BearSSLClient:: _sslio_closing = true ;
174
+ _sslio_closing = true ;
176
175
br_sslio_close (&_ioc);
177
176
}
178
177
@@ -314,7 +313,7 @@ int BearSSLClient::connectSSL(const char* host)
314
313
br_x509_minimal_set_time (&_xc, days, sec);
315
314
316
315
// 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 );
318
317
319
318
br_sslio_flush (&_ioc);
320
319
@@ -335,12 +334,13 @@ int BearSSLClient::connectSSL(const char* host)
335
334
336
335
int BearSSLClient::clientRead (void *ctx, unsigned char *buf, size_t len)
337
336
{
338
- if (BearSSLClient::_sslio_closing) {
337
+ BearSSLClient* bc = (BearSSLClient*)ctx;
338
+ Client* c = bc->_client ;
339
+
340
+ if (bc->_sslio_closing ) {
339
341
return -1 ;
340
342
}
341
343
342
- Client* c = (Client*)ctx;
343
-
344
344
if (!c->connected ()) {
345
345
return -1 ;
346
346
}
@@ -370,12 +370,13 @@ int BearSSLClient::clientRead(void *ctx, unsigned char *buf, size_t len)
370
370
371
371
int BearSSLClient::clientWrite (void *ctx, const unsigned char *buf, size_t len)
372
372
{
373
- if (BearSSLClient::_sslio_closing) {
373
+ BearSSLClient* bc = (BearSSLClient*)ctx;
374
+ Client* c = bc->_client ;
375
+
376
+ if (bc->_sslio_closing ) {
374
377
return -1 ;
375
378
}
376
379
377
- Client* c = (Client*)ctx;
378
-
379
380
#ifdef DEBUGSERIAL
380
381
DEBUGSERIAL.print (" BearSSLClient::clientWrite - " );
381
382
DEBUGSERIAL.print (len);
0 commit comments