diff --git a/SourceCode/arduino/lib/Firewall/esp32Storage.cpp b/SourceCode/arduino/lib/Firewall/esp32Storage.cpp index 2474c49..3a374a9 100644 --- a/SourceCode/arduino/lib/Firewall/esp32Storage.cpp +++ b/SourceCode/arduino/lib/Firewall/esp32Storage.cpp @@ -53,4 +53,18 @@ namespace firewall this->preferences.putUChar("target", rule_ptr->target); this->preferences.end(); } + + void Storage::store_certificate(httpsserver::SSLCert *certificate) + { + unsigned char *pk_data = certificate->getPKData(); + uint16_t pk_length = certificate->getPKLength(); + unsigned char *cert_data = certificate->getCertData(); + uint16_t cert_length = certificate->getCertLength(); + this->preferences.begin("certificate", false); + this->preferences.putBytes("pk_data", pk_data, sizeof(pk_data)); + this->preferences.putUInt("pk_length", pk_length); + this->preferences.putBytes("cert_data", cert_data, sizeof(cert_data)); + this->preferences.putUInt("pk_length", cert_length); + this->preferences.end(); + } } diff --git a/SourceCode/arduino/lib/Firewall/esp32Storage.hpp b/SourceCode/arduino/lib/Firewall/esp32Storage.hpp index aa16cfe..4c58bc4 100644 --- a/SourceCode/arduino/lib/Firewall/esp32Storage.hpp +++ b/SourceCode/arduino/lib/Firewall/esp32Storage.hpp @@ -4,6 +4,7 @@ #include "Preferences.h" #include "FirewallTypes.h" #include "mbedtls/md.h" +#include "SSLCert.hpp" namespace firewall { @@ -17,6 +18,7 @@ namespace firewall void store_amount_of_firewall_rules(const uint8_t); firewall_rule_t *retrieve_firewall_rule(const uint8_t); void store_firewall_rule(const uint8_t &, firewall_rule_t *); + void store_certificate(httpsserver::SSLCert *certificate); public: Storage();