Skip to content

Commit 8ad6c48

Browse files
committed
Allow built-in trust anchors to be overrided via constructor
1 parent 73c5ae5 commit 8ad6c48

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/BearSSLClient.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@
3131
#include "BearSSLClient.h"
3232

3333
BearSSLClient::BearSSLClient(Client& client) :
34-
_client(&client)
34+
BearSSLClient(client, TAs, TAs_NUM)
35+
{
36+
}
37+
38+
BearSSLClient::BearSSLClient(Client& client, const br_x509_trust_anchor* myTAs, int myNumTAs) :
39+
_client(&client),
40+
_TAs(myTAs),
41+
_numTAs(myNumTAs)
3542
{
3643
_ecKey.curve = 0;
3744
_ecKey.x = NULL;
@@ -234,7 +241,7 @@ void BearSSLClient::setEccSlot(int ecc508KeySlot, const char cert[])
234241
int BearSSLClient::connectSSL(const char* host)
235242
{
236243
// initialize client context with all algorithms and hardcoded trust anchors
237-
br_ssl_client_init_full(&_sc, &_xc, TAs, TAs_NUM);
244+
br_ssl_client_init_full(&_sc, &_xc, _TAs, _numTAs);
238245

239246
// set the buffer in split mode
240247
br_ssl_engine_set_buffer(&_sc.eng, _iobuf, sizeof(_iobuf), 1);

src/BearSSLClient.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class BearSSLClient : public Client {
3838

3939
public:
4040
BearSSLClient(Client& client);
41+
BearSSLClient(Client& client, const br_x509_trust_anchor* myTAs, int myNumTAs);
4142
virtual ~BearSSLClient();
4243

4344
virtual int connect(IPAddress ip, uint16_t port);
@@ -65,7 +66,10 @@ class BearSSLClient : public Client {
6566
static void clientAppendCert(void *ctx, const void *data, size_t len);
6667

6768
private:
68-
Client* _client;
69+
Client* _client;
70+
const br_x509_trust_anchor* _TAs;
71+
int _numTAs;
72+
6973
br_ec_private_key _ecKey;
7074
br_x509_certificate _ecCert;
7175
bool _ecCertDynamic;

0 commit comments

Comments
 (0)