From b55bdc9c0bb68236aa2de0a8eaec9f4c80cc2769 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Wed, 5 Sep 2018 23:54:48 +0200 Subject: Code style and clarity. --- examples/example6_certificateVerifier.hpp | 38 ++++++++++++++++--------------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'examples/example6_certificateVerifier.hpp') diff --git a/examples/example6_certificateVerifier.hpp b/examples/example6_certificateVerifier.hpp index b4b47a2a..3d8bf82e 100644 --- a/examples/example6_certificateVerifier.hpp +++ b/examples/example6_certificateVerifier.hpp @@ -3,20 +3,23 @@ #if VMIME_HAVE_TLS_SUPPORT // Certificate verifier (TLS/SSL) -class interactiveCertificateVerifier : public vmime::security::cert::defaultCertificateVerifier -{ +class interactiveCertificateVerifier : public vmime::security::cert::defaultCertificateVerifier { + public: - void verify(const vmime::shared_ptr & chain, const vmime::string& hostname) - { - try - { + void verify( + const vmime::shared_ptr & chain, + const vmime::string& hostname + ) { + + try { + setX509TrustedCerts(m_trustedCerts); defaultCertificateVerifier::verify(chain, hostname); - } - catch (vmime::security::cert::certificateException&) - { + + } catch (vmime::security::cert::certificateException&) { + // Obtain subject's certificate vmime::shared_ptr cert = chain->getAt(0); @@ -29,13 +32,14 @@ public: std::getline(std::cin, answer); if (answer.length() != 0 && - (answer[0] == 'Y' || answer[0] == 'y')) - { + (answer[0] == 'Y' || answer[0] == 'y')) { + // Accept it, and remember user's choice for later - if (cert->getType() == "X.509") - { - m_trustedCerts.push_back(vmime::dynamicCast - (cert)); + if (cert->getType() == "X.509") { + + m_trustedCerts.push_back( + vmime::dynamicCast (cert) + ); setX509TrustedCerts(m_trustedCerts); defaultCertificateVerifier::verify(chain, hostname); @@ -44,8 +48,7 @@ public: return; } - throw vmime::security::cert::certificateException - ("User did not accept the certificate."); + throw vmime::security::cert::certificateException("User did not accept the certificate."); } } @@ -59,4 +62,3 @@ std::vector > interactiveCertificateVerifier::m_trustedCerts; #endif // VMIME_HAVE_TLS_SUPPORT - -- cgit v1.2.3