Skip to content

Commit e701c97

Browse files
committed
latest sources from main repository
1 parent f7b1357 commit e701c97

9 files changed

Lines changed: 70 additions & 51 deletions

NetSSL_OpenSSL/include/Poco/Net/CertificateHandlerFactory.h

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// CertificateHandlerFactory.h
33
//
4-
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/CertificateHandlerFactory.h#6 $
4+
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/CertificateHandlerFactory.h#7 $
55
//
66
// Library: NetSSL_OpenSSL
77
// Package: SSLCore
@@ -82,22 +82,32 @@ class NetSSL_API CertificateHandlerFactoryRegistrar
8282
/// Destroys the CertificateHandlerFactoryRegistrar.
8383
};
8484

85-
86-
#define POCO_REGISTER_CHFACTORY(API, PKCLS) \
87-
class API PKCLS##Factory: public Poco::Net::CertificateHandlerFactory \
88-
{ \
89-
public: \
90-
PKCLS##Factory(){} \
91-
~PKCLS##Factory(){} \
92-
Poco::Net::InvalidCertificateHandler* create(bool server) const \
93-
{ \
94-
return new PKCLS(server); \
95-
} \
96-
}; \
97-
static Poco::Net::CertificateHandlerFactoryRegistrar aRegistrar(std::string(#PKCLS), new PKCLS##Factory());
85+
template <typename T>
86+
class CertificateHandlerFactoryImpl: public Poco::Net::CertificateHandlerFactory
87+
{
88+
public:
89+
CertificateHandlerFactoryImpl()
90+
{
91+
}
92+
93+
~CertificateHandlerFactoryImpl()
94+
{
95+
}
96+
97+
InvalidCertificateHandler* create(bool server) const
98+
{
99+
return new T(server);
100+
}
101+
};
98102

99103

100104
} } // namespace Poco::Net
101105

102106

107+
// DEPRECATED: register the factory directly at the FactoryMgr:
108+
// Poco::Net::SSLManager::instance().certificateHandlerFactoryMgr().setFactory(name, new Poco::Net::CertificateHandlerFactoryImpl<MyConsoleHandler>());
109+
#define POCO_REGISTER_CHFACTORY(API, PKCLS) \
110+
static Poco::Net::CertificateHandlerFactoryRegistrar aRegistrar(std::string(#PKCLS), new Poco::Net::CertificateHandlerFactoryImpl<PKCLS>());
111+
112+
103113
#endif // NetSSL_CertificateHandlerFactory_INCLUDED

NetSSL_OpenSSL/include/Poco/Net/PrivateKeyFactory.h

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// PrivateKeyFactory.h
33
//
4-
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/PrivateKeyFactory.h#6 $
4+
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/PrivateKeyFactory.h#7 $
55
//
66
// Library: NetSSL_OpenSSL
77
// Package: SSLCore
@@ -84,21 +84,32 @@ class NetSSL_API PrivateKeyFactoryRegistrar
8484
};
8585

8686

87-
#define POCO_REGISTER_KEYFACTORY(API, PKCLS) \
88-
class API PKCLS##Factory: public Poco::Net::PrivateKeyFactory \
89-
{ \
90-
public: \
91-
PKCLS##Factory(){} \
92-
~PKCLS##Factory(){} \
93-
Poco::Net::PrivateKeyPassphraseHandler* create(bool server) const \
94-
{ \
95-
return new PKCLS(server); \
96-
} \
97-
}; \
98-
static Poco::Net::PrivateKeyFactoryRegistrar aRegistrar(std::string(#PKCLS), new PKCLS##Factory());
87+
template<typename T>
88+
class PrivateKeyFactoryImpl: public Poco::Net::PrivateKeyFactory
89+
{
90+
public:
91+
PrivateKeyFactoryImpl()
92+
{
93+
}
94+
95+
~PrivateKeyFactoryImpl()
96+
{
97+
}
98+
99+
PrivateKeyPassphraseHandler* create(bool server) const
100+
{
101+
return new T(server);
102+
}
103+
};
99104

100105

101106
} } // namespace Poco::Net
102107

103108

109+
// DEPRECATED: register the factory directly at the FactoryMgr:
110+
// Poco::Net::SSLManager::instance().privateKeyFactoryMgr().setFactory(name, new Poco::Net::PrivateKeyFactoryImpl<MyKeyHandler>());
111+
#define POCO_REGISTER_KEYFACTORY(API, PKCLS) \
112+
static Poco::Net::PrivateKeyFactoryRegistrar aRegistrar(std::string(#PKCLS), new Poco::Net::PrivateKeyFactoryImpl<PKCLS>());
113+
114+
104115
#endif // NetSSL_PrivateKeyFactory_INCLUDED

NetSSL_OpenSSL/src/AcceptCertificateHandler.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// AcceptCertificateHandler.cpp
33
//
4-
// $Id: //poco/Main/NetSSL_OpenSSL/src/AcceptCertificateHandler.cpp#9 $
4+
// $Id: //poco/Main/NetSSL_OpenSSL/src/AcceptCertificateHandler.cpp#10 $
55
//
66
// Library: NetSSL_OpenSSL
77
// Package: SSLCore
@@ -35,7 +35,6 @@
3535

3636

3737
#include "Poco/Net/AcceptCertificateHandler.h"
38-
#include "Poco/Net/CertificateHandlerFactory.h"
3938

4039

4140
namespace Poco {
@@ -52,7 +51,4 @@ AcceptCertificateHandler::~AcceptCertificateHandler()
5251
}
5352

5453

55-
POCO_REGISTER_CHFACTORY(NetSSL_API, AcceptCertificateHandler)
56-
57-
5854
} } // namespace Poco::Net

NetSSL_OpenSSL/src/CertificateHandlerFactoryMgr.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// CertificateHandlerFactoryMgr.cpp
33
//
4-
// $Id: //poco/Main/NetSSL_OpenSSL/src/CertificateHandlerFactoryMgr.cpp#8 $
4+
// $Id: //poco/Main/NetSSL_OpenSSL/src/CertificateHandlerFactoryMgr.cpp#9 $
55
//
66
// Library: NetSSL_OpenSSL
77
// Package: SSLCore
@@ -35,6 +35,8 @@
3535

3636

3737
#include "Poco/Net/CertificateHandlerFactoryMgr.h"
38+
#include "Poco/Net/ConsoleCertificateHandler.h"
39+
#include "Poco/Net/AcceptCertificateHandler.h"
3840

3941

4042
namespace Poco {
@@ -43,6 +45,9 @@ namespace Net {
4345

4446
CertificateHandlerFactoryMgr::CertificateHandlerFactoryMgr()
4547
{
48+
setFactory("ConsoleCertificateHandler", new CertificateHandlerFactoryImpl<ConsoleCertificateHandler>());
49+
setFactory("AcceptCertificateHandler", new CertificateHandlerFactoryImpl<AcceptCertificateHandler>());
50+
4651
}
4752

4853

NetSSL_OpenSSL/src/ConsoleCertificateHandler.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// ConsoleCertificateHandler.cpp
33
//
4-
// $Id: //poco/Main/NetSSL_OpenSSL/src/ConsoleCertificateHandler.cpp#9 $
4+
// $Id: //poco/Main/NetSSL_OpenSSL/src/ConsoleCertificateHandler.cpp#10 $
55
//
66
// Library: NetSSL_OpenSSL
77
// Package: SSLCore
@@ -36,7 +36,6 @@
3636

3737
#include "Poco/Net/ConsoleCertificateHandler.h"
3838
#include <iostream>
39-
#include "Poco/Net/CertificateHandlerFactory.h"
4039

4140

4241
namespace Poco {
@@ -72,7 +71,4 @@ void ConsoleCertificateHandler::onInvalidCertificate(const void*, VerificationEr
7271
}
7372

7473

75-
POCO_REGISTER_CHFACTORY(NetSSL_API, ConsoleCertificateHandler)
76-
77-
7874
} } // namespace Poco::Net

NetSSL_OpenSSL/src/KeyConsoleHandler.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// KeyConsoleHandler.cpp
33
//
4-
// $Id: //poco/Main/NetSSL_OpenSSL/src/KeyConsoleHandler.cpp#9 $
4+
// $Id: //poco/Main/NetSSL_OpenSSL/src/KeyConsoleHandler.cpp#10 $
55
//
66
// Library: NetSSL_OpenSSL
77
// Package: SSLCore
@@ -35,7 +35,6 @@
3535

3636

3737
#include "Poco/Net/KeyConsoleHandler.h"
38-
#include "Poco/Net/PrivateKeyFactory.h"
3938
#include <iostream>
4039

4140

@@ -60,7 +59,4 @@ void KeyConsoleHandler::onPrivateKeyRequested(const void* pSender, std::string&
6059
}
6160

6261

63-
POCO_REGISTER_KEYFACTORY(NetSSL_API, KeyConsoleHandler)
64-
65-
6662
} } // namespace Poco::Net

NetSSL_OpenSSL/src/KeyFileHandler.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// KeyFileHandler.cpp
33
//
4-
// $Id: //poco/Main/NetSSL_OpenSSL/src/KeyFileHandler.cpp#10 $
4+
// $Id: //poco/Main/NetSSL_OpenSSL/src/KeyFileHandler.cpp#11 $
55
//
66
// Library: NetSSL_OpenSSL
77
// Package: SSLCore
@@ -35,7 +35,6 @@
3535

3636

3737
#include "Poco/Net/KeyFileHandler.h"
38-
#include "Poco/Net/PrivateKeyFactory.h"
3938
#include "Poco/Net/SSLManager.h"
4039
#include "Poco/File.h"
4140
#include "Poco/Util/LayeredConfiguration.h"
@@ -73,7 +72,4 @@ void KeyFileHandler::onPrivateKeyRequested(const void* pSender, std::string& pri
7372
}
7473

7574

76-
POCO_REGISTER_KEYFACTORY(NetSSL_API,KeyFileHandler)
77-
78-
7975
} } // namespace Poco::Net

NetSSL_OpenSSL/src/PrivateKeyFactoryMgr.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// PrivateKeyFactoryMgr.cpp
33
//
4-
// $Id: //poco/Main/NetSSL_OpenSSL/src/PrivateKeyFactoryMgr.cpp#8 $
4+
// $Id: //poco/Main/NetSSL_OpenSSL/src/PrivateKeyFactoryMgr.cpp#9 $
55
//
66
// Library: NetSSL_OpenSSL
77
// Package: SSLCore
@@ -35,6 +35,8 @@
3535

3636

3737
#include "Poco/Net/PrivateKeyFactoryMgr.h"
38+
#include "Poco/Net/KeyFileHandler.h"
39+
#include "Poco/Net/KeyConsoleHandler.h"
3840

3941

4042
namespace Poco {
@@ -43,6 +45,8 @@ namespace Net {
4345

4446
PrivateKeyFactoryMgr::PrivateKeyFactoryMgr()
4547
{
48+
setFactory("KeyFileHandler", new PrivateKeyFactoryImpl<KeyFileHandler>());
49+
setFactory("KeyConsoleHandler", new PrivateKeyFactoryImpl<KeyConsoleHandler>());
4650
}
4751

4852

NetSSL_OpenSSL/src/SecureSocketImpl.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// SecureSocketImpl.cpp
33
//
4-
// $Id: //poco/Main/NetSSL_OpenSSL/src/SecureSocketImpl.cpp#20 $
4+
// $Id: //poco/Main/NetSSL_OpenSSL/src/SecureSocketImpl.cpp#21 $
55
//
66
// Library: NetSSL_OpenSSL
77
// Package: SSLSockets
@@ -576,8 +576,13 @@ bool SecureSocketImpl::containsWildcards(const std::string& commonName)
576576

577577
bool SecureSocketImpl::matchByAlias(const std::string& alias, const HostEntry& heData)
578578
{
579+
// fix wildcards
580+
std::string aliasRep = Poco::replace(alias, "*", ".*");
581+
Poco::replaceInPlace(aliasRep, "..*", ".*");
582+
Poco::replaceInPlace(aliasRep, "?", ".?");
583+
Poco::replaceInPlace(aliasRep, "..?", ".?");
579584
// compare by name
580-
Poco::RegularExpression expr(alias);
585+
Poco::RegularExpression expr(aliasRep);
581586
bool found = false;
582587
const HostEntry::AliasList& aliases = heData.aliases();
583588
HostEntry::AliasList::const_iterator it = aliases.begin();

0 commit comments

Comments
 (0)