move certs into secret file
This commit is contained in:
parent
80e1d1599d
commit
1b338ce065
10 changed files with 78 additions and 134 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace fw
|
||||
{
|
||||
API::API(const char *username, const char *password, const uint16_t port)
|
||||
API::API(const char *cert, const char *key, const char *username, const char *password, const uint16_t port)
|
||||
{
|
||||
if (this->setup_auth(username, password) == ERROR)
|
||||
endless_loop();
|
||||
|
@ -12,14 +12,16 @@ namespace fw
|
|||
this->server = new ESP8266WebServerSecure(port);
|
||||
this->serverCache = new ServerSessions(5);
|
||||
#endif
|
||||
this->setup_routing();
|
||||
Serial.println("Starting server...");
|
||||
this->setup_routing(cert, key);
|
||||
Serial.printf("Starting server on port %i...\n", port);
|
||||
this->server->begin();
|
||||
}
|
||||
|
||||
API::~API()
|
||||
{
|
||||
this->server->stop();
|
||||
}
|
||||
|
||||
void API::handle_client()
|
||||
{
|
||||
this->server->handleClient();
|
||||
|
@ -55,10 +57,10 @@ namespace fw
|
|||
}
|
||||
}
|
||||
|
||||
void API::setup_routing()
|
||||
void API::setup_routing(const char *cert, const char *key)
|
||||
{
|
||||
#ifdef ESP8266
|
||||
this->server->getServer().setRSACert(new BearSSL::X509List(serverCert), new BearSSL::PrivateKey(serverKey));
|
||||
this->server->getServer().setRSACert(new BearSSL::X509List(cert), new BearSSL::PrivateKey(key));
|
||||
this->server->getServer().setCache(serverCache);
|
||||
#endif
|
||||
this->server->on(UriRegex("/api/v1/firewall/([0-9]+)"), HTTP_GET, std::bind(&API::get_firewall_rule_handler, this));
|
||||
|
|
Reference in a new issue