1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Allow users to inherit and override CertStore (#7827)

Make installCertStore virtual so we can inherit from CertStore and override it
Create CertStoreBase to inherit from
This commit is contained in:
Paulo Cabral Sanz 2021-01-18 16:59:20 -03:00 committed by GitHub
parent f5fd5912fe
commit 85e2ffffe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -31,7 +31,15 @@
namespace BearSSL {
class CertStore {
class CertStoreBase {
public:
virtual ~CertStoreBase() {}
// Installs the cert store into the X509 decoder (normally via static function callbacks)
virtual void installCertStore(br_x509_minimal_context *ctx) = 0;
};
class CertStore: public CertStoreBase {
public:
CertStore() { };
~CertStore();

View File

@ -110,7 +110,7 @@ class WiFiClientSecureCtx : public WiFiClient {
int getLastSSLError(char *dest = NULL, size_t len = 0);
// Attach a preconfigured certificate store
void setCertStore(CertStore *certStore) {
void setCertStore(CertStoreBase *certStore) {
_certStore = certStore;
}
@ -140,7 +140,7 @@ class WiFiClientSecureCtx : public WiFiClient {
std::shared_ptr<unsigned char> _iobuf_out;
time_t _now;
const X509List *_ta;
CertStore *_certStore;
CertStoreBase *_certStore;
int _iobuf_in_size;
int _iobuf_out_size;
bool _handshake_done;
@ -274,7 +274,7 @@ class WiFiClientSecure : public WiFiClient {
int getLastSSLError(char *dest = NULL, size_t len = 0) { return _ctx->getLastSSLError(dest, len); }
// Attach a preconfigured certificate store
void setCertStore(CertStore *certStore) { _ctx->setCertStore(certStore); }
void setCertStore(CertStoreBase *certStore) { _ctx->setCertStore(certStore); }
// Select specific ciphers (i.e. optimize for speed over security)
// These may be in PROGMEM or RAM, either will run properly