get certificate from storage
This commit is contained in:
parent
fe65ae4866
commit
d457949a76
2 changed files with 23 additions and 6 deletions
|
@ -33,10 +33,10 @@ namespace firewall
|
|||
sprintf(rulename, "fw_rule_%i", key);
|
||||
this->preferences.begin(rulename, false);
|
||||
rule_ptr->key = key;
|
||||
strcpy(rule_ptr->source, this->preferences.getString("source").c_str());
|
||||
strcpy(rule_ptr->destination, this->preferences.getString("destination").c_str());
|
||||
rule_ptr->protocol = static_cast<firewall_protocol_t>(this->preferences.getUChar("protocol"));
|
||||
rule_ptr->target = static_cast<firewall_target_t>(this->preferences.getUChar("target"));
|
||||
strcpy(rule_ptr->source, this->preferences.getString("source", "").c_str());
|
||||
strcpy(rule_ptr->destination, this->preferences.getString("destination", "").c_str());
|
||||
rule_ptr->protocol = static_cast<firewall_protocol_t>(this->preferences.getUChar("protocol", FW_ALL));
|
||||
rule_ptr->target = static_cast<firewall_target_t>(this->preferences.getUChar("target", FW_ACCEPT));
|
||||
this->preferences.end();
|
||||
return rule_ptr;
|
||||
}
|
||||
|
@ -54,6 +54,22 @@ namespace firewall
|
|||
this->preferences.end();
|
||||
}
|
||||
|
||||
httpsserver::SSLCert *Storage::retrieve_certificate()
|
||||
{
|
||||
unsigned char *pk_data;
|
||||
uint16_t pk_length;
|
||||
unsigned char *cert_data;
|
||||
uint16_t cert_length;
|
||||
this->preferences.begin("certificate", false);
|
||||
pk_length = this->preferences.getUInt("pk_length", 0);
|
||||
cert_length = this->preferences.getUInt("pk_length", 0);
|
||||
this->preferences.getBytes("pk_data", pk_data, pk_length);
|
||||
this->preferences.getBytes("cert_data", cert_data, cert_length);
|
||||
this->preferences.end();
|
||||
httpsserver::SSLCert *certificate = new httpsserver::SSLCert(cert_data, cert_length, pk_data, pk_length);
|
||||
return certificate;
|
||||
}
|
||||
|
||||
void Storage::store_certificate(httpsserver::SSLCert *certificate)
|
||||
{
|
||||
unsigned char *pk_data = certificate->getPKData();
|
||||
|
@ -61,9 +77,9 @@ namespace firewall
|
|||
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.putBytes("pk_data", pk_data, pk_length);
|
||||
this->preferences.putUInt("pk_length", pk_length);
|
||||
this->preferences.putBytes("cert_data", cert_data, sizeof(cert_data));
|
||||
this->preferences.putBytes("cert_data", cert_data, cert_length);
|
||||
this->preferences.putUInt("pk_length", cert_length);
|
||||
this->preferences.end();
|
||||
}
|
||||
|
|
|
@ -18,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 *);
|
||||
httpsserver::SSLCert *retrieve_certificate();
|
||||
void store_certificate(httpsserver::SSLCert *certificate);
|
||||
|
||||
public:
|
||||
|
|
Reference in a new issue