Fixed compile error without SSL/TLS lib

pull/36/head release-1.16.0
Tatsuhiro Tsujikawa 2012-12-01 23:37:57 +09:00
parent 2cbdd8b845
commit 8ac433a8e9
4 changed files with 14 additions and 3 deletions

View File

@ -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(),

View File

@ -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();

View File

@ -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)
{

View File

@ -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_;