Merge pull request #540 from RangelReale/sslserver

* Allows SecureStreamSocket::attach to be used in server connections
This commit is contained in:
Günter Obiltschnig 2014-09-17 11:43:43 +02:00
Родитель 4d4947c6cb 21f2e115eb
Коммит 6533fbda7f
2 изменённых файлов: 25 добавлений и 7 удалений

Просмотреть файл

@ -358,7 +358,7 @@ long SecureSocketImpl::verifyPeerCertificateImpl(const std::string& hostName)
{
Context::VerificationMode mode = _pContext->verificationMode();
if (mode == Context::VERIFY_NONE || !_pContext->extendedCertificateVerificationEnabled() ||
(isLocalHost(hostName) && mode != Context::VERIFY_STRICT))
(mode != Context::VERIFY_STRICT && isLocalHost(hostName)))
{
return X509_V_OK;
}

Просмотреть файл

@ -153,7 +153,10 @@ SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket)
{
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), SSLManager::instance().defaultClientContext());
SecureStreamSocket result(pImpl);
pImpl->connectSSL();
if (pImpl->context()->isForServerUse())
pImpl->acceptSSL();
else
pImpl->connectSSL();
return result;
}
@ -162,7 +165,10 @@ SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket,
{
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), pContext);
SecureStreamSocket result(pImpl);
pImpl->connectSSL();
if (pImpl->context()->isForServerUse())
pImpl->acceptSSL();
else
pImpl->connectSSL();
return result;
}
@ -172,7 +178,10 @@ SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket,
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), pContext);
SecureStreamSocket result(pImpl);
result.useSession(pSession);
pImpl->connectSSL();
if (pImpl->context()->isForServerUse())
pImpl->acceptSSL();
else
pImpl->connectSSL();
return result;
}
@ -182,7 +191,10 @@ SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket,
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), SSLManager::instance().defaultClientContext());
SecureStreamSocket result(pImpl);
result.setPeerHostName(peerHostName);
pImpl->connectSSL();
if (pImpl->context()->isForServerUse())
pImpl->acceptSSL();
else
pImpl->connectSSL();
return result;
}
@ -192,7 +204,10 @@ SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket,
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), pContext);
SecureStreamSocket result(pImpl);
result.setPeerHostName(peerHostName);
pImpl->connectSSL();
if (pImpl->context()->isForServerUse())
pImpl->acceptSSL();
else
pImpl->connectSSL();
return result;
}
@ -203,7 +218,10 @@ SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket,
SecureStreamSocket result(pImpl);
result.setPeerHostName(peerHostName);
result.useSession(pSession);
pImpl->connectSSL();
if (pImpl->context()->isForServerUse())
pImpl->acceptSSL();
else
pImpl->connectSSL();
return result;
}