Commit ec58a270 authored by jan.koester's avatar jan.koester
Browse files

small fix

parent 6c40a62d
Loading
Loading
Loading
Loading
+31 −22
Changes for src/httpd.cpp: 31 added lines, 22 removed lines.
Original line number Diff line number Diff line
@@ -25,7 +25,9 @@
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/

#include <vector>
#include <fstream>
#include <iostream>

#include <netplus/socket.h>
#include <netplus/exception.h>
@@ -89,8 +91,18 @@ libhttppp::HttpD::HttpD(int argc, char** argv){
    try {
        if (sslcertpath && sslkeypath) {

            std::vector<char> cert,key;

            std::string cert,key;
            std::ifstream keyfile(sslkeypath);

            if(keyfile.is_open()){
                while(keyfile.peek() != EOF){
                    key.push_back((char)keyfile.get());
                }
                keyfile.close();
            }

            key.push_back('\0');

            std::ifstream certfile(sslcertpath);

@@ -101,17 +113,10 @@ libhttppp::HttpD::HttpD(int argc, char** argv){
                certfile.close();
            }

            std::ifstream keyfile(sslkeypath);
            cert.push_back('\0');
            
            if(keyfile.is_open()){
                while(keyfile.peek() != EOF){
                    key.push_back((char)keyfile.get());
                }
                keyfile.close();
            }
            
            _ServerSocket = new netplus::ssl(httpaddr, port, maxconnections,-1,(const unsigned char*)cert.c_str(),
                                             cert.length(),(const unsigned char*)key.c_str(),key.length());
            _ServerSocket = new netplus::ssl(httpaddr, port, maxconnections,-1,(const unsigned char*)cert.data(),
                                             cert.size(),(const unsigned char*)key.data(),key.size());
        }else{
            #ifndef Windows
            if (portset == true)
@@ -134,7 +139,18 @@ libhttppp::HttpD::HttpD(const char *httpaddr, int port,int maxconnections,const
    try {
        if (sslcertpath && sslkeypath) {

            std::string cert,key;
            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();
            }

            key.push_back('\0');

            std::ifstream certfile(sslcertpath);

@@ -145,17 +161,10 @@ libhttppp::HttpD::HttpD(const char *httpaddr, int port,int maxconnections,const
                certfile.close();
            }

            std::ifstream keyfile(sslkeypath);

            if(keyfile.is_open()){
                while(keyfile.peek() != EOF){
                    key.push_back((char)keyfile.get());
                }
                keyfile.close();
            }
            cert.push_back('\0');

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