1//
2// InvalidCertificateHandler.cpp
3//
4// Library: NetSSL_OpenSSL
5// Package: SSLCore
6// Module: InvalidCertificateHandler
7//
8// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
9// and Contributors.
10//
11// SPDX-License-Identifier: BSL-1.0
12//
13
14
15#include "Poco/Net/InvalidCertificateHandler.h"
16#include "Poco/Net/SSLManager.h"
17#include "Poco/Delegate.h"
18
19
20using Poco::Delegate;
21
22
23namespace Poco {
24namespace Net {
25
26
27InvalidCertificateHandler::InvalidCertificateHandler(bool handleErrorsOnServerSide): _handleErrorsOnServerSide(handleErrorsOnServerSide)
28{
29 if (_handleErrorsOnServerSide)
30 SSLManager::instance().ServerVerificationError += Delegate<InvalidCertificateHandler, VerificationErrorArgs>(this, &InvalidCertificateHandler::onInvalidCertificate);
31 else
32 SSLManager::instance().ClientVerificationError += Delegate<InvalidCertificateHandler, VerificationErrorArgs>(this, &InvalidCertificateHandler::onInvalidCertificate);
33}
34
35
36InvalidCertificateHandler::~InvalidCertificateHandler()
37{
38 try
39 {
40 if (_handleErrorsOnServerSide)
41 SSLManager::instance().ServerVerificationError -= Delegate<InvalidCertificateHandler, VerificationErrorArgs>(this, &InvalidCertificateHandler::onInvalidCertificate);
42 else
43 SSLManager::instance().ClientVerificationError -= Delegate<InvalidCertificateHandler, VerificationErrorArgs>(this, &InvalidCertificateHandler::onInvalidCertificate);
44 }
45 catch (...)
46 {
47 poco_unexpected();
48 }
49}
50
51
52} } // namespace Poco::Net
53