3434
3535#include  " BearSSLClient.h" 
3636
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);
38- 
39- 
4037bool  BearSSLClient::_sslio_closing = false ;
4138
39+ BearSSLClient::BearSSLClient () :
40+   _noSNI(false ),
41+   _get_time_func(nullptr )
42+ {
43+   _ecKey.curve  = 0 ;
44+   _ecKey.x  = NULL ;
45+   _ecKey.xlen  = 0 ;
46+ 
47+   _ecCert.data  = NULL ;
48+   _ecCert.data_len  = 0 ;
49+   _ecCertDynamic = false ;
50+ }
4251
4352BearSSLClient::BearSSLClient (Client* client, const  br_x509_trust_anchor* myTAs, int  myNumTAs, GetTimeCallbackFunc func) :
4453  _client(client),
@@ -266,8 +275,8 @@ int BearSSLClient::connectSSL(const char* host)
266275  /*  Ensure this flag is cleared so we don't terminate a just starting connection. */ 
267276  _sslio_closing = false ;
268277
269-   //  initialize client context with all necessary  algorithms and hardcoded  trust anchors. 
270-   aiotc_client_profile_init (&_sc, &_xc, _TAs, _numTAs);
278+   //  initialize client context with enabled  algorithms and trust anchors
279+   _br_ssl_client_init_function (&_sc, &_xc, _TAs, _numTAs);
271280
272281  br_ssl_engine_set_buffers_bidi (&_sc.eng , _ibuf, sizeof (_ibuf), _obuf, sizeof (_obuf));
273282
@@ -278,7 +287,7 @@ int BearSSLClient::connectSSL(const char* host)
278287    //  ECC508 random success, add custom ECDSA vfry and EC sign
279288    br_ssl_engine_set_ecdsa (&_sc.eng , eccX08_vrfy_asn1);
280289    br_x509_minimal_set_ecdsa (&_xc, br_ssl_engine_get_ec (&_sc.eng ), br_ssl_engine_get_ecdsa (&_sc.eng ));
281-      
290+ 
282291    //  enable client auth using the ECCX08
283292    if  (_ecCert.data_len  && _ecKey.xlen ) {
284293      br_ssl_client_set_single_ec (&_sc, &_ecCert, 1 , &_ecKey, BR_KEYTYPE_KEYX | BR_KEYTYPE_SIGN, BR_KEYTYPE_EC, br_ec_get_default (), eccX08_sign_asn1);
0 commit comments