Loading src/httpd.cpp +10 −44 Original line number Diff line number Diff line Loading @@ -1645,29 +1645,15 @@ libhttppp::HttpD::HttpD(int argc, char** argv) { throw _httpexception; } netplus::x509cert x509; x509.loadFromFile(derfile); if (!x509.checkValidity()) { _httpexception[HTTPException::Critical] << "invalid certfile!"; netplus::ssl::CertificateBundle bundle; if (!bundle.loadFromFile(derfile, keyder)) { _httpexception[HTTPException::Critical] << "failed to load cert/key: " << derfile; throw _httpexception; } // Load private key from DER file std::ifstream keyfile(keyder, std::ios::binary | std::ios::ate); if (!keyfile) { _httpexception[HTTPException::Critical] << "cannot open private key file: " << keyder; if (!bundle.cert.checkValidity()) { _httpexception[HTTPException::Critical] << "invalid certfile!"; throw _httpexception; } size_t keysize = keyfile.tellg(); keyfile.seekg(0, std::ios::beg); std::vector<uint8_t> keydata(keysize); keyfile.read(reinterpret_cast<char*>(keydata.data()), keysize); keyfile.close(); netplus::ssl::CertificateBundle bundle; bundle.cert = x509; bundle.privateKeyDer = keydata; bundle.rsa_key = netplus::rsa(keydata); _certBundle[httpaddr] = bundle; auto tss = std::make_unique<netplus::ssl>(_certBundle, httpaddr, port, maxconnections, -1); Loading Loading @@ -1698,36 +1684,16 @@ libhttppp::HttpD::HttpD(const std::string& httpaddr, int port,int maxconnections try { _fileServer = false; if (!sslcertpath.empty()) { if (sslkeypath.empty()) { _httpexception[HTTPException::Critical] << "httpsder set but httpskeyder missing"; netplus::ssl::CertificateBundle bundle; if (!bundle.loadFromFile(sslcertpath, sslkeypath)) { _httpexception[HTTPException::Critical] << "failed to load cert/key: " << sslcertpath; throw _httpexception; } netplus::x509cert x509; x509.loadFromFile(sslcertpath); if (!x509.checkValidity()) { if (!bundle.cert.checkValidity()) { _httpexception[HTTPException::Critical] << "invalid certfile!"; throw _httpexception; } netplus::ssl::CertificateBundle bundle; bundle.cert = x509; // Load private key from DER file std::ifstream keyfile(sslkeypath, std::ios::binary | std::ios::ate); if (!keyfile) { _httpexception[HTTPException::Critical] << "cannot open private key file: " << sslkeypath; throw _httpexception; } size_t keysize = keyfile.tellg(); keyfile.seekg(0, std::ios::beg); std::vector<uint8_t> keydata(keysize); keyfile.read(reinterpret_cast<char*>(keydata.data()), keysize); keyfile.close(); bundle.privateKeyDer = keydata; bundle.rsa_key = netplus::rsa(keydata); _certBundle[httpaddr] = bundle; auto tss = std::make_unique<netplus::ssl>(_certBundle, httpaddr, port, maxconnections, -1); auto qss = std::make_unique<netplus::quic>(_certBundle, httpaddr, port, maxconnections, -1); Loading Loading
src/httpd.cpp +10 −44 Original line number Diff line number Diff line Loading @@ -1645,29 +1645,15 @@ libhttppp::HttpD::HttpD(int argc, char** argv) { throw _httpexception; } netplus::x509cert x509; x509.loadFromFile(derfile); if (!x509.checkValidity()) { _httpexception[HTTPException::Critical] << "invalid certfile!"; netplus::ssl::CertificateBundle bundle; if (!bundle.loadFromFile(derfile, keyder)) { _httpexception[HTTPException::Critical] << "failed to load cert/key: " << derfile; throw _httpexception; } // Load private key from DER file std::ifstream keyfile(keyder, std::ios::binary | std::ios::ate); if (!keyfile) { _httpexception[HTTPException::Critical] << "cannot open private key file: " << keyder; if (!bundle.cert.checkValidity()) { _httpexception[HTTPException::Critical] << "invalid certfile!"; throw _httpexception; } size_t keysize = keyfile.tellg(); keyfile.seekg(0, std::ios::beg); std::vector<uint8_t> keydata(keysize); keyfile.read(reinterpret_cast<char*>(keydata.data()), keysize); keyfile.close(); netplus::ssl::CertificateBundle bundle; bundle.cert = x509; bundle.privateKeyDer = keydata; bundle.rsa_key = netplus::rsa(keydata); _certBundle[httpaddr] = bundle; auto tss = std::make_unique<netplus::ssl>(_certBundle, httpaddr, port, maxconnections, -1); Loading Loading @@ -1698,36 +1684,16 @@ libhttppp::HttpD::HttpD(const std::string& httpaddr, int port,int maxconnections try { _fileServer = false; if (!sslcertpath.empty()) { if (sslkeypath.empty()) { _httpexception[HTTPException::Critical] << "httpsder set but httpskeyder missing"; netplus::ssl::CertificateBundle bundle; if (!bundle.loadFromFile(sslcertpath, sslkeypath)) { _httpexception[HTTPException::Critical] << "failed to load cert/key: " << sslcertpath; throw _httpexception; } netplus::x509cert x509; x509.loadFromFile(sslcertpath); if (!x509.checkValidity()) { if (!bundle.cert.checkValidity()) { _httpexception[HTTPException::Critical] << "invalid certfile!"; throw _httpexception; } netplus::ssl::CertificateBundle bundle; bundle.cert = x509; // Load private key from DER file std::ifstream keyfile(sslkeypath, std::ios::binary | std::ios::ate); if (!keyfile) { _httpexception[HTTPException::Critical] << "cannot open private key file: " << sslkeypath; throw _httpexception; } size_t keysize = keyfile.tellg(); keyfile.seekg(0, std::ios::beg); std::vector<uint8_t> keydata(keysize); keyfile.read(reinterpret_cast<char*>(keydata.data()), keysize); keyfile.close(); bundle.privateKeyDer = keydata; bundle.rsa_key = netplus::rsa(keydata); _certBundle[httpaddr] = bundle; auto tss = std::make_unique<netplus::ssl>(_certBundle, httpaddr, port, maxconnections, -1); auto qss = std::make_unique<netplus::quic>(_certBundle, httpaddr, port, maxconnections, -1); Loading