34
34
35
35
#include " BearSSLClient.h"
36
36
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 ;
38
38
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);
39
40
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 ;
41
48
49
+ _ecCert.data = NULL ;
50
+ _ecCert.data_len = 0 ;
51
+ _ecCertDynamic = false ;
52
+ }
42
53
43
54
BearSSLClient::BearSSLClient (Client* client, const br_x509_trust_anchor* myTAs, int myNumTAs, GetTimeCallbackFunc func) :
44
55
_client(client),
45
56
_TAs(myTAs),
46
57
_numTAs(myNumTAs),
47
58
_noSNI(false ),
48
- _get_time_func(func)
59
+ _get_time_func(func),
60
+ _br_ssl_client_init_function(aiotc_client_profile_init)
49
61
{
50
62
assert (_get_time_func != nullptr );
51
63
@@ -266,8 +278,8 @@ int BearSSLClient::connectSSL(const char* host)
266
278
/* Ensure this flag is cleared so we don't terminate a just starting connection. */
267
279
_sslio_closing = false ;
268
280
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);
271
283
272
284
br_ssl_engine_set_buffers_bidi (&_sc.eng , _ibuf, sizeof (_ibuf), _obuf, sizeof (_obuf));
273
285
@@ -278,7 +290,7 @@ int BearSSLClient::connectSSL(const char* host)
278
290
// ECC508 random success, add custom ECDSA vfry and EC sign
279
291
br_ssl_engine_set_ecdsa (&_sc.eng , eccX08_vrfy_asn1);
280
292
br_x509_minimal_set_ecdsa (&_xc, br_ssl_engine_get_ec (&_sc.eng ), br_ssl_engine_get_ecdsa (&_sc.eng ));
281
-
293
+
282
294
// enable client auth using the ECCX08
283
295
if (_ecCert.data_len && _ecKey.xlen ) {
284
296
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