Commit 183a1b0d authored by jan.koester's avatar jan.koester
Browse files

test

parent cc830a4c
Loading
Loading
Loading
Loading
+14 −24
Changes for src/httpd.cpp: 14 added lines, 24 removed lines.
Original line number Diff line number Diff line
@@ -222,35 +222,25 @@ libhttppp::HttpD::HttpD(const std::string& httpaddr, int port,int maxconnections
		_ServerSocket = nullptr;

		_fileServer = false;

        if (!sslcertpath.empty() && !sslkeypath.empty()) {

            std::vector<char> cert,key;

            std::ifstream keyfile(sslkeypath);

            if(keyfile.is_open()){
                while(keyfile.peek() != EOF){
                    key.push_back((char)keyfile.get());
                }
                keyfile.close();
        if (!sslcertpath.empty()) {
                if (sslkeypath.empty()) {
                    _httpexception[HTTPException::Critical] << "httpsder set but httpskeyder missing";
                    throw _httpexception;
                }

            key.push_back('\0');

            std::ifstream certfile(sslcertpath);

            if(certfile.is_open()){
                while(certfile.peek() != EOF){
                    cert.push_back((char)certfile.get());
                }
                certfile.close();
                netplus::x509cert x509;
                x509.loadFromFile(sslcertpath);
                if (!x509.checkValidity()) {
                    _httpexception[HTTPException::Critical] << "invalid certfile!";
                    throw _httpexception;
                }

            cert.push_back('\0');
                auto ss = std::make_unique<netplus::ssl>(httpaddr, port, maxconnections, -1, x509);

                // IMPORTANT: load private key to fill ss->_rsa.n/e/d
                ss->loadServerPrivateKeyDer(sslkeypath);

 //           _ServerSocket = new netplus::ssl(httpaddr, port, maxconnections,-1,(const unsigned char*)cert.data(),
 //                                            cert.size(),(const unsigned char*)key.data(),key.size());
                _ServerSocket = std::move(ss);
        }else{
            #ifndef Windows
            if (port != -1)