Explorar o código

Fixed compile error without SSL/TLS lib

Tatsuhiro Tsujikawa %!s(int64=13) %!d(string=hai) anos
pai
achega
8ac433a8e9
Modificáronse 4 ficheiros con 14 adicións e 3 borrados
  1. 2 0
      src/HttpRequestCommand.cc
  2. 2 0
      src/HttpServerCommand.cc
  3. 4 0
      src/SocketCore.cc
  4. 6 3
      src/SocketCore.h

+ 2 - 0
src/HttpRequestCommand.cc

@@ -128,6 +128,7 @@ bool HttpRequestCommand::executeInternal() {
         getRequest()->getConnectedAddr(), getRequest()->getConnectedPort())) {
       return true;
     }
+#ifdef ENABLE_SSL
     if(getRequest()->getProtocol() == "https") {
       if(!getSocket()->tlsConnect(getRequest()->getHost())) {
         setReadCheckSocketIf(getSocket(), getSocket()->wantRead());
@@ -136,6 +137,7 @@ bool HttpRequestCommand::executeInternal() {
         return false;
       }
     }
+#endif // ENABLE_SSL
     if(getSegments().empty()) {
       SharedHandle<HttpRequest> httpRequest
         (createHttpRequest(getRequest(),

+ 2 - 0
src/HttpServerCommand.cc

@@ -178,6 +178,7 @@ bool HttpServerCommand::execute()
        !httpServer_->getSocketRecvBuffer()->bufferEmpty()) {
       timeoutTimer_ = global::wallclock();
 
+#ifdef ENABLE_SSL
       if(httpServer_->getSecure()) {
         // tlsAccept() just returns true if handshake has already
         // finished.
@@ -187,6 +188,7 @@ bool HttpServerCommand::execute()
           return false;
         }
       }
+#endif // ENABLE_SSL
 
       SharedHandle<HttpHeader> header;
       header = httpServer_->receiveRequest();

+ 4 - 0
src/SocketCore.cc

@@ -829,6 +829,8 @@ void SocketCore::readData(char* data, size_t& len)
   len = ret;
 }
 
+#ifdef ENABLE_SSL
+
 bool SocketCore::tlsAccept()
 {
   return tlsHandshake(svTlsContext_.get(), A2STR::NIL);
@@ -1162,6 +1164,8 @@ bool SocketCore::tlsHandshake(TLSContext* tlsctx, const std::string& hostname)
   return true;
 }
 
+#endif // ENABLE_SSL
+
 ssize_t SocketCore::writeData(const char* data, size_t len,
                               const std::string& host, uint16_t port)
 {

+ 6 - 3
src/SocketCore.h

@@ -109,14 +109,15 @@ private:
 
   void setSockOpt(int level, int optname, void* optval, socklen_t optlen);
 
+#ifdef ENABLE_SSL
   /**
-   * Makes this socket secure.
-   * If the system has not OpenSSL, then this method do nothing.
-   * connection must be established  before calling this method.
+   * Makes this socket secure. The connection must be established
+   * before calling this method.
    *
    * If you are going to verify peer's certificate, hostname must be supplied.
    */
   bool tlsHandshake(TLSContext* tlsctx, const std::string& hostname);
+#endif // ENABLE_SSL
 
   SocketCore(sock_t sockfd, int sockType);
 public:
@@ -305,6 +306,7 @@ public:
     return readDataFrom(reinterpret_cast<char*>(data), len, sender);
   }
 
+#ifdef ENABLE_SSL
   // Performs TLS server side handshake. If handshake is completed,
   // returns true. If handshake has not been done yet, returns false.
   bool tlsAccept();
@@ -315,6 +317,7 @@ public:
   // If you are going to verify peer's certificate, hostname must be
   // supplied.
   bool tlsConnect(const std::string& hostname);
+#endif // ENABLE_SSL
 
   bool operator==(const SocketCore& s) {
     return sockfd_ == s.sockfd_;