Skip to content

Commit 85e2fff

Browse files
authored
Allow users to inherit and override CertStore (esp8266#7827)
Make installCertStore virtual so we can inherit from CertStore and override it Create CertStoreBase to inherit from
1 parent f5fd591 commit 85e2fff

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

libraries/ESP8266WiFi/src/CertStoreBearSSL.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@
3131

3232
namespace BearSSL {
3333

34-
class CertStore {
34+
class CertStoreBase {
35+
public:
36+
virtual ~CertStoreBase() {}
37+
38+
// Installs the cert store into the X509 decoder (normally via static function callbacks)
39+
virtual void installCertStore(br_x509_minimal_context *ctx) = 0;
40+
};
41+
42+
class CertStore: public CertStoreBase {
3543
public:
3644
CertStore() { };
3745
~CertStore();

libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class WiFiClientSecureCtx : public WiFiClient {
110110
int getLastSSLError(char *dest = NULL, size_t len = 0);
111111

112112
// Attach a preconfigured certificate store
113-
void setCertStore(CertStore *certStore) {
113+
void setCertStore(CertStoreBase *certStore) {
114114
_certStore = certStore;
115115
}
116116

@@ -140,7 +140,7 @@ class WiFiClientSecureCtx : public WiFiClient {
140140
std::shared_ptr<unsigned char> _iobuf_out;
141141
time_t _now;
142142
const X509List *_ta;
143-
CertStore *_certStore;
143+
CertStoreBase *_certStore;
144144
int _iobuf_in_size;
145145
int _iobuf_out_size;
146146
bool _handshake_done;
@@ -274,7 +274,7 @@ class WiFiClientSecure : public WiFiClient {
274274
int getLastSSLError(char *dest = NULL, size_t len = 0) { return _ctx->getLastSSLError(dest, len); }
275275

276276
// Attach a preconfigured certificate store
277-
void setCertStore(CertStore *certStore) { _ctx->setCertStore(certStore); }
277+
void setCertStore(CertStoreBase *certStore) { _ctx->setCertStore(certStore); }
278278

279279
// Select specific ciphers (i.e. optimize for speed over security)
280280
// These may be in PROGMEM or RAM, either will run properly

0 commit comments

Comments
 (0)