mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-16 18:56:52 +02:00
latest sources from main repository
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// CertificateHandlerFactory.h
|
// CertificateHandlerFactory.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/CertificateHandlerFactory.h#6 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/CertificateHandlerFactory.h#7 $
|
||||||
//
|
//
|
||||||
// Library: NetSSL_OpenSSL
|
// Library: NetSSL_OpenSSL
|
||||||
// Package: SSLCore
|
// Package: SSLCore
|
||||||
@@ -82,22 +82,32 @@ public:
|
|||||||
/// Destroys the CertificateHandlerFactoryRegistrar.
|
/// Destroys the CertificateHandlerFactoryRegistrar.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class CertificateHandlerFactoryImpl: public Poco::Net::CertificateHandlerFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CertificateHandlerFactoryImpl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#define POCO_REGISTER_CHFACTORY(API, PKCLS) \
|
~CertificateHandlerFactoryImpl()
|
||||||
class API PKCLS##Factory: public Poco::Net::CertificateHandlerFactory \
|
{
|
||||||
{ \
|
}
|
||||||
public: \
|
|
||||||
PKCLS##Factory(){} \
|
InvalidCertificateHandler* create(bool server) const
|
||||||
~PKCLS##Factory(){} \
|
{
|
||||||
Poco::Net::InvalidCertificateHandler* create(bool server) const \
|
return new T(server);
|
||||||
{ \
|
}
|
||||||
return new PKCLS(server); \
|
};
|
||||||
} \
|
|
||||||
}; \
|
|
||||||
static Poco::Net::CertificateHandlerFactoryRegistrar aRegistrar(std::string(#PKCLS), new PKCLS##Factory());
|
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
} } // namespace Poco::Net
|
||||||
|
|
||||||
|
|
||||||
|
// DEPRECATED: register the factory directly at the FactoryMgr:
|
||||||
|
// Poco::Net::SSLManager::instance().certificateHandlerFactoryMgr().setFactory(name, new Poco::Net::CertificateHandlerFactoryImpl<MyConsoleHandler>());
|
||||||
|
#define POCO_REGISTER_CHFACTORY(API, PKCLS) \
|
||||||
|
static Poco::Net::CertificateHandlerFactoryRegistrar aRegistrar(std::string(#PKCLS), new Poco::Net::CertificateHandlerFactoryImpl<PKCLS>());
|
||||||
|
|
||||||
|
|
||||||
#endif // NetSSL_CertificateHandlerFactory_INCLUDED
|
#endif // NetSSL_CertificateHandlerFactory_INCLUDED
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// PrivateKeyFactory.h
|
// PrivateKeyFactory.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/PrivateKeyFactory.h#6 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/PrivateKeyFactory.h#7 $
|
||||||
//
|
//
|
||||||
// Library: NetSSL_OpenSSL
|
// Library: NetSSL_OpenSSL
|
||||||
// Package: SSLCore
|
// Package: SSLCore
|
||||||
@@ -84,21 +84,32 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define POCO_REGISTER_KEYFACTORY(API, PKCLS) \
|
template<typename T>
|
||||||
class API PKCLS##Factory: public Poco::Net::PrivateKeyFactory \
|
class PrivateKeyFactoryImpl: public Poco::Net::PrivateKeyFactory
|
||||||
{ \
|
{
|
||||||
public: \
|
public:
|
||||||
PKCLS##Factory(){} \
|
PrivateKeyFactoryImpl()
|
||||||
~PKCLS##Factory(){} \
|
{
|
||||||
Poco::Net::PrivateKeyPassphraseHandler* create(bool server) const \
|
}
|
||||||
{ \
|
|
||||||
return new PKCLS(server); \
|
~PrivateKeyFactoryImpl()
|
||||||
} \
|
{
|
||||||
}; \
|
}
|
||||||
static Poco::Net::PrivateKeyFactoryRegistrar aRegistrar(std::string(#PKCLS), new PKCLS##Factory());
|
|
||||||
|
PrivateKeyPassphraseHandler* create(bool server) const
|
||||||
|
{
|
||||||
|
return new T(server);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
} } // namespace Poco::Net
|
||||||
|
|
||||||
|
|
||||||
|
// DEPRECATED: register the factory directly at the FactoryMgr:
|
||||||
|
// Poco::Net::SSLManager::instance().privateKeyFactoryMgr().setFactory(name, new Poco::Net::PrivateKeyFactoryImpl<MyKeyHandler>());
|
||||||
|
#define POCO_REGISTER_KEYFACTORY(API, PKCLS) \
|
||||||
|
static Poco::Net::PrivateKeyFactoryRegistrar aRegistrar(std::string(#PKCLS), new Poco::Net::PrivateKeyFactoryImpl<PKCLS>());
|
||||||
|
|
||||||
|
|
||||||
#endif // NetSSL_PrivateKeyFactory_INCLUDED
|
#endif // NetSSL_PrivateKeyFactory_INCLUDED
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// AcceptCertificateHandler.cpp
|
// AcceptCertificateHandler.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/src/AcceptCertificateHandler.cpp#9 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/src/AcceptCertificateHandler.cpp#10 $
|
||||||
//
|
//
|
||||||
// Library: NetSSL_OpenSSL
|
// Library: NetSSL_OpenSSL
|
||||||
// Package: SSLCore
|
// Package: SSLCore
|
||||||
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Poco/Net/AcceptCertificateHandler.h"
|
#include "Poco/Net/AcceptCertificateHandler.h"
|
||||||
#include "Poco/Net/CertificateHandlerFactory.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@@ -52,7 +51,4 @@ AcceptCertificateHandler::~AcceptCertificateHandler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
POCO_REGISTER_CHFACTORY(NetSSL_API, AcceptCertificateHandler)
|
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
} } // namespace Poco::Net
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// CertificateHandlerFactoryMgr.cpp
|
// CertificateHandlerFactoryMgr.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/src/CertificateHandlerFactoryMgr.cpp#8 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/src/CertificateHandlerFactoryMgr.cpp#9 $
|
||||||
//
|
//
|
||||||
// Library: NetSSL_OpenSSL
|
// Library: NetSSL_OpenSSL
|
||||||
// Package: SSLCore
|
// Package: SSLCore
|
||||||
@@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Poco/Net/CertificateHandlerFactoryMgr.h"
|
#include "Poco/Net/CertificateHandlerFactoryMgr.h"
|
||||||
|
#include "Poco/Net/ConsoleCertificateHandler.h"
|
||||||
|
#include "Poco/Net/AcceptCertificateHandler.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@@ -43,6 +45,9 @@ namespace Net {
|
|||||||
|
|
||||||
CertificateHandlerFactoryMgr::CertificateHandlerFactoryMgr()
|
CertificateHandlerFactoryMgr::CertificateHandlerFactoryMgr()
|
||||||
{
|
{
|
||||||
|
setFactory("ConsoleCertificateHandler", new CertificateHandlerFactoryImpl<ConsoleCertificateHandler>());
|
||||||
|
setFactory("AcceptCertificateHandler", new CertificateHandlerFactoryImpl<AcceptCertificateHandler>());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ConsoleCertificateHandler.cpp
|
// ConsoleCertificateHandler.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/src/ConsoleCertificateHandler.cpp#9 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/src/ConsoleCertificateHandler.cpp#10 $
|
||||||
//
|
//
|
||||||
// Library: NetSSL_OpenSSL
|
// Library: NetSSL_OpenSSL
|
||||||
// Package: SSLCore
|
// Package: SSLCore
|
||||||
@@ -36,7 +36,6 @@
|
|||||||
|
|
||||||
#include "Poco/Net/ConsoleCertificateHandler.h"
|
#include "Poco/Net/ConsoleCertificateHandler.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Poco/Net/CertificateHandlerFactory.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@@ -72,7 +71,4 @@ void ConsoleCertificateHandler::onInvalidCertificate(const void*, VerificationEr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
POCO_REGISTER_CHFACTORY(NetSSL_API, ConsoleCertificateHandler)
|
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
} } // namespace Poco::Net
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// KeyConsoleHandler.cpp
|
// KeyConsoleHandler.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/src/KeyConsoleHandler.cpp#9 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/src/KeyConsoleHandler.cpp#10 $
|
||||||
//
|
//
|
||||||
// Library: NetSSL_OpenSSL
|
// Library: NetSSL_OpenSSL
|
||||||
// Package: SSLCore
|
// Package: SSLCore
|
||||||
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Poco/Net/KeyConsoleHandler.h"
|
#include "Poco/Net/KeyConsoleHandler.h"
|
||||||
#include "Poco/Net/PrivateKeyFactory.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
@@ -60,7 +59,4 @@ void KeyConsoleHandler::onPrivateKeyRequested(const void* pSender, std::string&
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
POCO_REGISTER_KEYFACTORY(NetSSL_API, KeyConsoleHandler)
|
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
} } // namespace Poco::Net
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// KeyFileHandler.cpp
|
// KeyFileHandler.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/src/KeyFileHandler.cpp#10 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/src/KeyFileHandler.cpp#11 $
|
||||||
//
|
//
|
||||||
// Library: NetSSL_OpenSSL
|
// Library: NetSSL_OpenSSL
|
||||||
// Package: SSLCore
|
// Package: SSLCore
|
||||||
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Poco/Net/KeyFileHandler.h"
|
#include "Poco/Net/KeyFileHandler.h"
|
||||||
#include "Poco/Net/PrivateKeyFactory.h"
|
|
||||||
#include "Poco/Net/SSLManager.h"
|
#include "Poco/Net/SSLManager.h"
|
||||||
#include "Poco/File.h"
|
#include "Poco/File.h"
|
||||||
#include "Poco/Util/LayeredConfiguration.h"
|
#include "Poco/Util/LayeredConfiguration.h"
|
||||||
@@ -73,7 +72,4 @@ void KeyFileHandler::onPrivateKeyRequested(const void* pSender, std::string& pri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
POCO_REGISTER_KEYFACTORY(NetSSL_API,KeyFileHandler)
|
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
} } // namespace Poco::Net
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// PrivateKeyFactoryMgr.cpp
|
// PrivateKeyFactoryMgr.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/src/PrivateKeyFactoryMgr.cpp#8 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/src/PrivateKeyFactoryMgr.cpp#9 $
|
||||||
//
|
//
|
||||||
// Library: NetSSL_OpenSSL
|
// Library: NetSSL_OpenSSL
|
||||||
// Package: SSLCore
|
// Package: SSLCore
|
||||||
@@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Poco/Net/PrivateKeyFactoryMgr.h"
|
#include "Poco/Net/PrivateKeyFactoryMgr.h"
|
||||||
|
#include "Poco/Net/KeyFileHandler.h"
|
||||||
|
#include "Poco/Net/KeyConsoleHandler.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@@ -43,6 +45,8 @@ namespace Net {
|
|||||||
|
|
||||||
PrivateKeyFactoryMgr::PrivateKeyFactoryMgr()
|
PrivateKeyFactoryMgr::PrivateKeyFactoryMgr()
|
||||||
{
|
{
|
||||||
|
setFactory("KeyFileHandler", new PrivateKeyFactoryImpl<KeyFileHandler>());
|
||||||
|
setFactory("KeyConsoleHandler", new PrivateKeyFactoryImpl<KeyConsoleHandler>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// SecureSocketImpl.cpp
|
// SecureSocketImpl.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/src/SecureSocketImpl.cpp#20 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/src/SecureSocketImpl.cpp#21 $
|
||||||
//
|
//
|
||||||
// Library: NetSSL_OpenSSL
|
// Library: NetSSL_OpenSSL
|
||||||
// Package: SSLSockets
|
// Package: SSLSockets
|
||||||
@@ -576,8 +576,13 @@ bool SecureSocketImpl::containsWildcards(const std::string& commonName)
|
|||||||
|
|
||||||
bool SecureSocketImpl::matchByAlias(const std::string& alias, const HostEntry& heData)
|
bool SecureSocketImpl::matchByAlias(const std::string& alias, const HostEntry& heData)
|
||||||
{
|
{
|
||||||
|
// fix wildcards
|
||||||
|
std::string aliasRep = Poco::replace(alias, "*", ".*");
|
||||||
|
Poco::replaceInPlace(aliasRep, "..*", ".*");
|
||||||
|
Poco::replaceInPlace(aliasRep, "?", ".?");
|
||||||
|
Poco::replaceInPlace(aliasRep, "..?", ".?");
|
||||||
// compare by name
|
// compare by name
|
||||||
Poco::RegularExpression expr(alias);
|
Poco::RegularExpression expr(aliasRep);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
const HostEntry::AliasList& aliases = heData.aliases();
|
const HostEntry::AliasList& aliases = heData.aliases();
|
||||||
HostEntry::AliasList::const_iterator it = aliases.begin();
|
HostEntry::AliasList::const_iterator it = aliases.begin();
|
||||||
|
Reference in New Issue
Block a user