mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 12:18:01 +01:00
Added support for loading certificates and private key pairs from PKCS #12 files, as well as loading certificates (without private key) from PEM or DER files. Some code restructuring and cleanup.
This commit is contained in:
69
NetSSL_Win/src/PrivateKeyFactoryMgr.cpp
Normal file
69
NetSSL_Win/src/PrivateKeyFactoryMgr.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// PrivateKeyFactoryMgr.cpp
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: NetSSL_Win
|
||||
// Package: SSLCore
|
||||
// Module: PrivateKeyFactoryMgr
|
||||
//
|
||||
// Copyright (c) 2006-2014, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Net/PrivateKeyFactoryMgr.h"
|
||||
#include "Poco/Net/KeyFileHandler.h"
|
||||
#include "Poco/Net/KeyConsoleHandler.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
PrivateKeyFactoryMgr::PrivateKeyFactoryMgr()
|
||||
{
|
||||
setFactory("KeyFileHandler", new PrivateKeyFactoryImpl<KeyFileHandler>());
|
||||
setFactory("KeyConsoleHandler", new PrivateKeyFactoryImpl<KeyConsoleHandler>());
|
||||
}
|
||||
|
||||
|
||||
PrivateKeyFactoryMgr::~PrivateKeyFactoryMgr()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PrivateKeyFactoryMgr::setFactory(const std::string& name, PrivateKeyFactory* pFactory)
|
||||
{
|
||||
bool success = _factories.insert(make_pair(name, Poco::SharedPtr<PrivateKeyFactory>(pFactory))).second;
|
||||
if (!success)
|
||||
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);
|
||||
if (it != _factories.end())
|
||||
return it->second;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void PrivateKeyFactoryMgr::removeFactory(const std::string& name)
|
||||
{
|
||||
_factories.erase(name);
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
Reference in New Issue
Block a user