mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2026-09-20 22:07:11 +02:00
Update POCO library.
This commit is contained in:
@@ -42,14 +42,14 @@ void CertificateHandlerFactoryMgr::setFactory(const std::string& name, Certifica
|
||||
delete pFactory;
|
||||
poco_assert(success);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CertificateHandlerFactoryMgr::hasFactory(const std::string& name) const
|
||||
{
|
||||
return _factories.find(name) != _factories.end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const CertificateHandlerFactory* CertificateHandlerFactoryMgr::getFactory(const std::string& name) const
|
||||
{
|
||||
FactoriesMap::const_iterator it = _factories.find(name);
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ int HTTPSClientSession::read(char* buffer, std::streamsize length)
|
||||
try
|
||||
{
|
||||
return HTTPSession::read(buffer, length);
|
||||
}
|
||||
}
|
||||
catch(SSLConnectionUnexpectedlyClosedException&)
|
||||
{
|
||||
return 0;
|
||||
|
||||
+8
-8
@@ -78,7 +78,7 @@ std::istream* HTTPSStreamFactory::open(const URI& uri)
|
||||
int redirects = 0;
|
||||
std::string username;
|
||||
std::string password;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
if (!pSession)
|
||||
@@ -107,7 +107,7 @@ std::istream* HTTPSStreamFactory::open(const URI& uri)
|
||||
std::string path = resolvedURI.getPathAndQuery();
|
||||
if (path.empty()) path = "/";
|
||||
HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1);
|
||||
|
||||
|
||||
if (authorize)
|
||||
{
|
||||
HTTPCredentials::extractCredentials(uri, username, password);
|
||||
@@ -117,8 +117,8 @@ std::istream* HTTPSStreamFactory::open(const URI& uri)
|
||||
|
||||
pSession->sendRequest(req);
|
||||
std::istream& rs = pSession->receiveResponse(res);
|
||||
bool moved = (res.getStatus() == HTTPResponse::HTTP_MOVED_PERMANENTLY ||
|
||||
res.getStatus() == HTTPResponse::HTTP_FOUND ||
|
||||
bool moved = (res.getStatus() == HTTPResponse::HTTP_MOVED_PERMANENTLY ||
|
||||
res.getStatus() == HTTPResponse::HTTP_FOUND ||
|
||||
res.getStatus() == HTTPResponse::HTTP_SEE_OTHER ||
|
||||
res.getStatus() == HTTPResponse::HTTP_TEMPORARY_REDIRECT);
|
||||
if (moved)
|
||||
@@ -129,7 +129,7 @@ std::istream* HTTPSStreamFactory::open(const URI& uri)
|
||||
resolvedURI.setUserInfo(username + ":" + password);
|
||||
authorize = false;
|
||||
}
|
||||
delete pSession;
|
||||
delete pSession;
|
||||
pSession = 0;
|
||||
++redirects;
|
||||
retry = true;
|
||||
@@ -140,9 +140,9 @@ std::istream* HTTPSStreamFactory::open(const URI& uri)
|
||||
}
|
||||
else if (res.getStatus() == HTTPResponse::HTTP_USEPROXY && !retry)
|
||||
{
|
||||
// The requested resource MUST be accessed through the proxy
|
||||
// given by the Location field. The Location field gives the
|
||||
// URI of the proxy. The recipient is expected to repeat this
|
||||
// The requested resource MUST be accessed through the proxy
|
||||
// given by the Location field. The Location field gives the
|
||||
// URI of the proxy. The recipient is expected to repeat this
|
||||
// single request via the proxy. 305 responses MUST only be generated by origin servers.
|
||||
// only use for one single request!
|
||||
proxyUri.resolve(res.get("Location"));
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ void KeyFileHandler::onPrivateKeyRequested(const void* pSender, std::string& pri
|
||||
std::string prefix = serverSide() ? SSLManager::CFG_SERVER_PREFIX : SSLManager::CFG_CLIENT_PREFIX;
|
||||
if (!config.hasProperty(prefix + CFG_PRIV_KEY_FILE))
|
||||
throw Poco::Util::EmptyOptionException(std::string("Missing Configuration Entry: ") + prefix + CFG_PRIV_KEY_FILE);
|
||||
|
||||
|
||||
privateKey = config.getString(prefix + CFG_PRIV_KEY_FILE);
|
||||
}
|
||||
catch (Poco::NullPointerException&)
|
||||
|
||||
+3
-3
@@ -40,14 +40,14 @@ void PrivateKeyFactoryMgr::setFactory(const std::string& name, PrivateKeyFactory
|
||||
delete pFactory;
|
||||
poco_assert(success);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool PrivateKeyFactoryMgr::hasFactory(const std::string& name) const
|
||||
{
|
||||
return _factories.find(name) != _factories.end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const PrivateKeyFactory* PrivateKeyFactoryMgr::getFactory(const std::string& name) const
|
||||
{
|
||||
FactoriesMap::const_iterator it = _factories.find(name);
|
||||
|
||||
+5
-5
@@ -129,7 +129,7 @@ Context::Ptr SSLManager::defaultClientContext()
|
||||
try
|
||||
{
|
||||
initDefaultContext(false);
|
||||
}
|
||||
}
|
||||
catch (Poco::IllegalStateException&)
|
||||
{
|
||||
_ptrClientCertificateHandler = new RejectCertificateHandler(false);
|
||||
@@ -221,7 +221,7 @@ void SSLManager::initDefaultContext(bool server)
|
||||
if (trustRoots) options |= Context::OPT_TRUST_ROOTS_WIN_CERT_STORE;
|
||||
if (useMachineStore) options |= Context::OPT_USE_MACHINE_STORE;
|
||||
if (useStrongCrypto) options |= Context::OPT_USE_STRONG_CRYPTO;
|
||||
if (!certPath.empty())
|
||||
if (!certPath.empty())
|
||||
{
|
||||
options |= Context::OPT_LOAD_CERT_FROM_FILE;
|
||||
certName = certPath;
|
||||
@@ -270,7 +270,7 @@ void SSLManager::initPassphraseHandler(bool server)
|
||||
{
|
||||
if (server && _ptrServerPassphraseHandler) return;
|
||||
if (!server && _ptrClientPassphraseHandler) return;
|
||||
|
||||
|
||||
std::string prefix = server ? CFG_SERVER_PREFIX : CFG_CLIENT_PREFIX;
|
||||
Poco::Util::AbstractConfiguration& config = appConfig();
|
||||
|
||||
@@ -352,7 +352,7 @@ void SSLManager::loadSecurityLibrary()
|
||||
#if defined(_WIN32_WCE)
|
||||
dllPath = L"Secur32.dll";
|
||||
#else
|
||||
if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT
|
||||
if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT
|
||||
&& VerInfo.dwMajorVersion == 4)
|
||||
{
|
||||
dllPath = L"Security.dll";
|
||||
@@ -432,7 +432,7 @@ Poco::Util::AbstractConfiguration& SSLManager::appConfig()
|
||||
void initializeSSL()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void uninitializeSSL()
|
||||
{
|
||||
|
||||
+6
-6
@@ -26,7 +26,7 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
SecureServerSocket::SecureServerSocket():
|
||||
SecureServerSocket::SecureServerSocket():
|
||||
ServerSocket(new SecureServerSocketImpl(SSLManager::instance().defaultServerContext()), true)
|
||||
{
|
||||
}
|
||||
@@ -38,7 +38,7 @@ SecureServerSocket::SecureServerSocket(Context::Ptr pContext):
|
||||
}
|
||||
|
||||
|
||||
SecureServerSocket::SecureServerSocket(const Socket& socket):
|
||||
SecureServerSocket::SecureServerSocket(const Socket& socket):
|
||||
ServerSocket(socket)
|
||||
{
|
||||
if (!dynamic_cast<SecureServerSocketImpl*>(impl()))
|
||||
@@ -46,7 +46,7 @@ SecureServerSocket::SecureServerSocket(const Socket& socket):
|
||||
}
|
||||
|
||||
|
||||
SecureServerSocket::SecureServerSocket(const SocketAddress& address, int backlog):
|
||||
SecureServerSocket::SecureServerSocket(const SocketAddress& address, int backlog):
|
||||
ServerSocket(new SecureServerSocketImpl(SSLManager::instance().defaultServerContext()), true)
|
||||
{
|
||||
impl()->bind(address, true);
|
||||
@@ -54,7 +54,7 @@ SecureServerSocket::SecureServerSocket(const SocketAddress& address, int backlog
|
||||
}
|
||||
|
||||
|
||||
SecureServerSocket::SecureServerSocket(const SocketAddress& address, int backlog, Context::Ptr pContext):
|
||||
SecureServerSocket::SecureServerSocket(const SocketAddress& address, int backlog, Context::Ptr pContext):
|
||||
ServerSocket(new SecureServerSocketImpl(pContext), true)
|
||||
{
|
||||
impl()->bind(address, true);
|
||||
@@ -62,7 +62,7 @@ SecureServerSocket::SecureServerSocket(const SocketAddress& address, int backlog
|
||||
}
|
||||
|
||||
|
||||
SecureServerSocket::SecureServerSocket(Poco::UInt16 port, int backlog):
|
||||
SecureServerSocket::SecureServerSocket(Poco::UInt16 port, int backlog):
|
||||
ServerSocket(new SecureServerSocketImpl(SSLManager::instance().defaultServerContext()), true)
|
||||
{
|
||||
IPAddress wildcardAddr;
|
||||
@@ -71,7 +71,7 @@ SecureServerSocket::SecureServerSocket(Poco::UInt16 port, int backlog):
|
||||
impl()->listen(backlog);
|
||||
}
|
||||
|
||||
SecureServerSocket::SecureServerSocket(Poco::UInt16 port, int backlog, Context::Ptr pContext):
|
||||
SecureServerSocket::SecureServerSocket(Poco::UInt16 port, int backlog, Context::Ptr pContext):
|
||||
ServerSocket(new SecureServerSocketImpl(pContext), true)
|
||||
{
|
||||
IPAddress wildcardAddr;
|
||||
|
||||
+11
-8
@@ -657,16 +657,16 @@ SECURITY_STATUS SecureSocketImpl::decodeBufferFull(BYTE* pBuffer, DWORD bufSize,
|
||||
}
|
||||
else
|
||||
{
|
||||
// everything decoded
|
||||
if (securityStatus != SEC_E_OK && securityStatus != SEC_E_INCOMPLETE_MESSAGE && securityStatus != SEC_I_RENEGOTIATE && securityStatus != SEC_I_CONTEXT_EXPIRED)
|
||||
{
|
||||
throw SSLException("Failed to decode data", Utility::formatError(securityStatus));
|
||||
}
|
||||
else if (securityStatus == SEC_E_OK)
|
||||
if (securityStatus == SEC_E_OK)
|
||||
{
|
||||
// everything decoded
|
||||
pBuffer = 0;
|
||||
bufSize = 0;
|
||||
}
|
||||
else if (securityStatus != SEC_E_INCOMPLETE_MESSAGE && securityStatus != SEC_I_RENEGOTIATE && securityStatus != SEC_I_CONTEXT_EXPIRED)
|
||||
{
|
||||
return securityStatus;
|
||||
}
|
||||
}
|
||||
|
||||
if (securityStatus == SEC_I_RENEGOTIATE)
|
||||
@@ -1317,7 +1317,7 @@ void SecureSocketImpl::verifyCertificateChainClient(PCCERT_CONTEXT pServerCert)
|
||||
|
||||
// Revocation check of the root certificate may fail due to missing CRL points, etc.
|
||||
// We ignore all errors checking the root certificate except CRYPT_E_REVOKED.
|
||||
if (!ok && (revStat.dwIndex < certs.size() - 1 || revStat.dwError == CRYPT_E_REVOKED))
|
||||
if (!ok && revStat.dwIndex < certs.size() - 1 && revStat.dwError == CRYPT_E_REVOKED)
|
||||
{
|
||||
VerificationErrorArgs args(cert, revStat.dwIndex, revStat.dwReason, Utility::formatError(revStat.dwError));
|
||||
SSLManager::instance().ClientVerificationError(this, args);
|
||||
@@ -1421,7 +1421,10 @@ void SecureSocketImpl::serverVerifyCertificate()
|
||||
CERT_VERIFY_REV_CHAIN_FLAG,
|
||||
NULL,
|
||||
&revStat);
|
||||
if (!ok && (revStat.dwIndex < certs.size() - 1 || revStat.dwError == CRYPT_E_REVOKED))
|
||||
|
||||
// Revocation check of the root certificate may fail due to missing CRL points, etc.
|
||||
// We ignore all errors checking the root certificate except CRYPT_E_REVOKED.
|
||||
if (!ok && revStat.dwIndex < certs.size() - 1 && revStat.dwError == CRYPT_E_REVOKED)
|
||||
{
|
||||
VerificationErrorArgs args(cert, revStat.dwIndex, revStat.dwReason, Utility::formatError(revStat.dwReason));
|
||||
SSLManager::instance().ServerVerificationError(this, args);
|
||||
|
||||
+15
-15
@@ -26,33 +26,33 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
SecureStreamSocket::SecureStreamSocket():
|
||||
SecureStreamSocket::SecureStreamSocket():
|
||||
StreamSocket(new SecureStreamSocketImpl(SSLManager::instance().defaultClientContext()))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SecureStreamSocket::SecureStreamSocket(Context::Ptr pContext):
|
||||
SecureStreamSocket::SecureStreamSocket(Context::Ptr pContext):
|
||||
StreamSocket(new SecureStreamSocketImpl(pContext))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SecureStreamSocket::SecureStreamSocket(Context::Ptr pContext, Session::Ptr pSession):
|
||||
SecureStreamSocket::SecureStreamSocket(Context::Ptr pContext, Session::Ptr pSession):
|
||||
StreamSocket(new SecureStreamSocketImpl(pContext))
|
||||
{
|
||||
useSession(pSession);
|
||||
}
|
||||
|
||||
|
||||
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address):
|
||||
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address):
|
||||
StreamSocket(new SecureStreamSocketImpl(SSLManager::instance().defaultClientContext()))
|
||||
{
|
||||
connect(address);
|
||||
}
|
||||
|
||||
|
||||
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::string& hostName):
|
||||
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::string& hostName):
|
||||
StreamSocket(new SecureStreamSocketImpl(SSLManager::instance().defaultClientContext()))
|
||||
{
|
||||
static_cast<SecureStreamSocketImpl*>(impl())->setPeerHostName(hostName);
|
||||
@@ -60,14 +60,14 @@ SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::
|
||||
}
|
||||
|
||||
|
||||
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, Context::Ptr pContext):
|
||||
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, Context::Ptr pContext):
|
||||
StreamSocket(new SecureStreamSocketImpl(pContext))
|
||||
{
|
||||
connect(address);
|
||||
}
|
||||
|
||||
|
||||
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, Context::Ptr pContext, Session::Ptr pSession):
|
||||
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, Context::Ptr pContext, Session::Ptr pSession):
|
||||
StreamSocket(new SecureStreamSocketImpl(pContext))
|
||||
{
|
||||
useSession(pSession);
|
||||
@@ -75,7 +75,7 @@ SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, Context::Pt
|
||||
}
|
||||
|
||||
|
||||
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::string& hostName, Context::Ptr pContext):
|
||||
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::string& hostName, Context::Ptr pContext):
|
||||
StreamSocket(new SecureStreamSocketImpl(pContext))
|
||||
{
|
||||
static_cast<SecureStreamSocketImpl*>(impl())->setPeerHostName(hostName);
|
||||
@@ -83,7 +83,7 @@ SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::
|
||||
}
|
||||
|
||||
|
||||
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::string& hostName, Context::Ptr pContext, Session::Ptr pSession):
|
||||
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::string& hostName, Context::Ptr pContext, Session::Ptr pSession):
|
||||
StreamSocket(new SecureStreamSocketImpl(pContext))
|
||||
{
|
||||
static_cast<SecureStreamSocketImpl*>(impl())->setPeerHostName(hostName);
|
||||
@@ -92,7 +92,7 @@ SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::
|
||||
}
|
||||
|
||||
|
||||
SecureStreamSocket::SecureStreamSocket(const Socket& socket):
|
||||
SecureStreamSocket::SecureStreamSocket(const Socket& socket):
|
||||
StreamSocket(socket)
|
||||
{
|
||||
if (!dynamic_cast<SecureStreamSocketImpl*>(impl()))
|
||||
@@ -100,7 +100,7 @@ SecureStreamSocket::SecureStreamSocket(const Socket& socket):
|
||||
}
|
||||
|
||||
|
||||
SecureStreamSocket::SecureStreamSocket(SocketImpl* pImpl):
|
||||
SecureStreamSocket::SecureStreamSocket(SocketImpl* pImpl):
|
||||
StreamSocket(pImpl)
|
||||
{
|
||||
if (!dynamic_cast<SecureStreamSocketImpl*>(impl()))
|
||||
@@ -140,7 +140,7 @@ void SecureStreamSocket::setPeerHostName(const std::string& hostName)
|
||||
static_cast<SecureStreamSocketImpl*>(impl())->setPeerHostName(hostName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const std::string& SecureStreamSocket::getPeerHostName() const
|
||||
{
|
||||
return static_cast<SecureStreamSocketImpl*>(impl())->getPeerHostName();
|
||||
@@ -217,7 +217,7 @@ void SecureStreamSocket::setLazyHandshake(bool flag)
|
||||
static_cast<SecureStreamSocketImpl*>(impl())->setLazyHandshake(flag);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool SecureStreamSocket::getLazyHandshake() const
|
||||
{
|
||||
return static_cast<SecureStreamSocketImpl*>(impl())->getLazyHandshake();
|
||||
@@ -247,13 +247,13 @@ Session::Ptr SecureStreamSocket::currentSession()
|
||||
return static_cast<SecureStreamSocketImpl*>(impl())->currentSession();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SecureStreamSocket::useSession(Session::Ptr pSession)
|
||||
{
|
||||
static_cast<SecureStreamSocketImpl*>(impl())->useSession(pSession);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool SecureStreamSocket::sessionWasReused()
|
||||
{
|
||||
return static_cast<SecureStreamSocketImpl*>(impl())->sessionWasReused();
|
||||
|
||||
+7
-7
@@ -67,7 +67,7 @@ void SecureStreamSocketImpl::connect(const SocketAddress& address, const Poco::T
|
||||
_impl.connect(address, timeout, !_lazyHandshake);
|
||||
reset(_impl.sockfd());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SecureStreamSocketImpl::connectNB(const SocketAddress& address)
|
||||
{
|
||||
@@ -80,19 +80,19 @@ void SecureStreamSocketImpl::connectSSL()
|
||||
{
|
||||
_impl.connectSSL(!_lazyHandshake);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SecureStreamSocketImpl::bind(const SocketAddress& address, bool reuseAddress)
|
||||
{
|
||||
throw Poco::InvalidAccessException("Cannot bind() a SecureStreamSocketImpl");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SecureStreamSocketImpl::listen(int backlog)
|
||||
{
|
||||
throw Poco::InvalidAccessException("Cannot listen() on a SecureStreamSocketImpl");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SecureStreamSocketImpl::close()
|
||||
{
|
||||
@@ -148,12 +148,12 @@ void SecureStreamSocketImpl::shutdownReceive()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SecureStreamSocketImpl::shutdownSend()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SecureStreamSocketImpl::shutdown()
|
||||
{
|
||||
_impl.shutdown();
|
||||
@@ -187,7 +187,7 @@ void SecureStreamSocketImpl::setLazyHandshake(bool flag)
|
||||
_lazyHandshake = flag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool SecureStreamSocketImpl::getLazyHandshake() const
|
||||
{
|
||||
return _lazyHandshake;
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// Some OpenSSL functions are deprecated in OS X 10.7
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
+9
-5
@@ -116,7 +116,7 @@ X509Certificate& X509Certificate::operator = (X509Certificate&& cert) noexcept
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::swap(X509Certificate& cert)
|
||||
void X509Certificate::swap(X509Certificate& cert) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
swap(cert._issuerName, _issuerName);
|
||||
@@ -278,10 +278,14 @@ void X509Certificate::extractNames(std::string& cmnName, std::set<std::string>&
|
||||
PCERT_ALT_NAME_INFO pNameInfo = reinterpret_cast<PCERT_ALT_NAME_INFO>(buffer.begin());
|
||||
for (int i = 0; i < pNameInfo->cAltEntry; i++)
|
||||
{
|
||||
std::wstring waltName(pNameInfo->rgAltEntry[i].pwszDNSName);
|
||||
std::string altName;
|
||||
Poco::UnicodeConverter::toUTF8(waltName, altName);
|
||||
domainNames.insert(altName);
|
||||
// Some certificates have Subject Alternative Name entries that are not DNS Name. Skip them.
|
||||
if (pNameInfo->rgAltEntry[i].dwAltNameChoice == CERT_ALT_NAME_DNS_NAME)
|
||||
{
|
||||
std::wstring waltName(pNameInfo->rgAltEntry[i].pwszDNSName);
|
||||
std::string altName;
|
||||
Poco::UnicodeConverter::toUTF8(waltName, altName);
|
||||
domainNames.insert(altName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user