1//
2// ConsoleCertificateHandler.cpp
3//
4// Library: NetSSL_OpenSSL
5// Package: SSLCore
6// Module: ConsoleCertificateHandler
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/ConsoleCertificateHandler.h"
16#include <iostream>
17
18
19namespace Poco {
20namespace Net {
21
22
23ConsoleCertificateHandler::ConsoleCertificateHandler(bool server): InvalidCertificateHandler(server)
24{
25}
26
27
28ConsoleCertificateHandler::~ConsoleCertificateHandler()
29{
30}
31
32
33void ConsoleCertificateHandler::onInvalidCertificate(const void*, VerificationErrorArgs& errorCert)
34{
35 const X509Certificate& aCert = errorCert.certificate();
36 std::cout << "\n";
37 std::cout << "WARNING: Certificate verification failed\n";
38 std::cout << "----------------------------------------\n";
39 std::cout << "Issuer Name: " << aCert.issuerName() << "\n";
40 std::cout << "Subject Name: " << aCert.subjectName() << "\n\n";
41 std::cout << "The certificate yielded the error: " << errorCert.errorMessage() << "\n\n";
42 std::cout << "The error occurred in the certificate chain at position " << errorCert.errorDepth() << "\n";
43 std::cout << "Accept the certificate (y,n)? ";
44 char c = 0;
45 std::cin >> c;
46 if (c == 'y' || c == 'Y')
47 errorCert.setIgnoreError(true);
48 else
49 errorCert.setIgnoreError(false);
50}
51
52
53} } // namespace Poco::Net
54