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) ;
37+ bool BearSSLClient::_sslio_closing = false ;
3838
39+ 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);
3940
40- bool BearSSLClient::_sslio_closing = false ;
41+ BearSSLClient::BearSSLClient () :
42+ _noSNI(false ),
43+ _get_time_func(nullptr )
44+ {
45+ _ecKey.curve = 0 ;
46+ _ecKey.x = NULL ;
47+ _ecKey.xlen = 0 ;
4148
49+ _ecCert.data = NULL ;
50+ _ecCert.data_len = 0 ;
51+ _ecCertDynamic = false ;
52+ }
4253
4354BearSSLClient::BearSSLClient (Client* client, const br_x509_trust_anchor* myTAs, int myNumTAs, GetTimeCallbackFunc func) :
4455 _client(client),
4556 _TAs(myTAs),
4657 _numTAs(myNumTAs),
4758 _noSNI(false ),
48- _get_time_func(func)
59+ _get_time_func(func),
60+ _br_ssl_client_init_function(aiotc_client_profile_init)
4961{
5062 assert (_get_time_func != nullptr );
5163
@@ -266,8 +278,8 @@ int BearSSLClient::connectSSL(const char* host)
266278 /* Ensure this flag is cleared so we don't terminate a just starting connection. */
267279 _sslio_closing = false ;
268280
269- // initialize client context with all necessary algorithms and hardcoded trust anchors.
270- aiotc_client_profile_init (&_sc, &_xc, _TAs, _numTAs);
281+ // initialize client context with enabled algorithms and trust anchors
282+ _br_ssl_client_init_function (&_sc, &_xc, _TAs, _numTAs);
271283
272284 br_ssl_engine_set_buffers_bidi (&_sc.eng , _ibuf, sizeof (_ibuf), _obuf, sizeof (_obuf));
273285
@@ -278,7 +290,7 @@ int BearSSLClient::connectSSL(const char* host)
278290 // ECC508 random success, add custom ECDSA vfry and EC sign
279291 br_ssl_engine_set_ecdsa (&_sc.eng , eccX08_vrfy_asn1);
280292 br_x509_minimal_set_ecdsa (&_xc, br_ssl_engine_get_ec (&_sc.eng ), br_ssl_engine_get_ecdsa (&_sc.eng ));
281-
293+
282294 // enable client auth using the ECCX08
283295 if (_ecCert.data_len && _ecKey.xlen ) {
284296 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