From 4522121196f11de0200ed54ea50830c1baf017a6 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sun, 30 Oct 2005 15:02:39 +0000 Subject: [PATCH] Moved certificate code into 'vmime::net::security::cert' namespace. --- SConstruct | 10 +++++----- examples/example6.cpp | 12 ++++++------ src/net/service.cpp | 8 ++++---- src/net/tls/TLSSession.cpp | 4 ++-- src/net/tls/TLSSocket.cpp | 14 +++++++------- .../tls => security/cert}/X509Certificate.cpp | 10 +++++----- .../tls => security/cert}/certificateChain.cpp | 10 +++++----- .../cert}/defaultCertificateVerifier.cpp | 12 ++++++------ vmime/net/service.hpp | 8 ++++---- vmime/net/tls/TLSSession.hpp | 8 ++++---- vmime/net/tls/TLSSocket.hpp | 4 ++-- .../tls => security/cert}/X509Certificate.hpp | 16 ++++++++-------- vmime/{net/tls => security/cert}/certificate.hpp | 14 +++++++------- .../tls => security/cert}/certificateChain.hpp | 16 ++++++++-------- .../cert}/certificateVerifier.hpp | 16 ++++++++-------- .../cert}/defaultCertificateVerifier.hpp | 16 ++++++++-------- vmime/vmime.hpp | 10 +++++----- 17 files changed, 94 insertions(+), 94 deletions(-) rename src/{net/tls => security/cert}/X509Certificate.cpp (97%) rename src/{net/tls => security/cert}/certificateChain.cpp (92%) rename src/{net/tls => security/cert}/defaultCertificateVerifier.cpp (95%) rename vmime/{net/tls => security/cert}/X509Certificate.hpp (93%) rename vmime/{net/tls => security/cert}/certificate.hpp (89%) rename vmime/{net/tls => security/cert}/certificateChain.hpp (87%) rename vmime/{net/tls => security/cert}/certificateVerifier.hpp (83%) rename vmime/{net/tls => security/cert}/defaultCertificateVerifier.hpp (86%) diff --git a/SConstruct b/SConstruct index 8848cf7a..796e3aeb 100644 --- a/SConstruct +++ b/SConstruct @@ -218,11 +218,11 @@ libvmime_messaging_sources = [ libvmime_net_tls_sources = [ 'net/tls/TLSSession.cpp', 'net/tls/TLSSession.hpp', 'net/tls/TLSSocket.cpp', 'net/tls/TLSSocket.hpp', - 'net/tls/certificateChain.cpp', 'net/tls/certificateChain.hpp', - 'net/tls/certificateVerifier.hpp', - 'net/tls/defaultCertificateVerifier.cpp', 'net/tls/defaultCertificateVerifier.hpp', - 'net/tls/certificate.hpp', - 'net/tls/X509Certificate.cpp', 'net/tls/X509Certificate.hpp' + 'security/cert/certificateChain.cpp', 'security/cert/certificateChain.hpp', + 'security/cert/certificateVerifier.hpp', + 'security/cert/defaultCertificateVerifier.cpp', 'security/cert/defaultCertificateVerifier.hpp', + 'security/cert/certificate.hpp', + 'security/cert/X509Certificate.cpp', 'security/cert/X509Certificate.hpp' ] libvmime_messaging_proto_sources = [ diff --git a/examples/example6.cpp b/examples/example6.cpp index bcbdcaf6..e64db44b 100644 --- a/examples/example6.cpp +++ b/examples/example6.cpp @@ -101,11 +101,11 @@ private: #if VMIME_HAVE_TLS_SUPPORT // Certificate verifier (TLS/SSL) -class interactiveCertificateVerifier : public vmime::net::tls::defaultCertificateVerifier +class interactiveCertificateVerifier : public vmime::security::cert::defaultCertificateVerifier { public: - void verify(vmime::ref chain) + void verify(vmime::ref chain) { try { @@ -116,7 +116,7 @@ public: catch (vmime::exceptions::certificate_verification_exception&) { // Obtain subject's certificate - vmime::ref cert = chain->getAt(0); + vmime::ref cert = chain->getAt(0); std::cout << std::endl; std::cout << "Server sent a '" << cert->getType() << "'" << " certificate." << std::endl; @@ -133,7 +133,7 @@ public: if (cert->getType() == "X.509") { m_trustedCerts.push_back(cert.dynamicCast - ()); + ()); } return; @@ -146,11 +146,11 @@ public: private: - static std::vector > m_trustedCerts; + static std::vector > m_trustedCerts; }; -std::vector > +std::vector > interactiveCertificateVerifier::m_trustedCerts; #endif // VMIME_HAVE_TLS_SUPPORT diff --git a/src/net/service.cpp b/src/net/service.cpp index 8dde675a..6b1c34f3 100644 --- a/src/net/service.cpp +++ b/src/net/service.cpp @@ -29,7 +29,7 @@ #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT - #include "vmime/net/tls/defaultCertificateVerifier.hpp" + #include "vmime/security/cert/defaultCertificateVerifier.hpp" #endif // VMIME_HAVE_TLS_SUPPORT @@ -53,7 +53,7 @@ service::service(ref sess, const serviceInfos& /* infos */, } #if VMIME_HAVE_TLS_SUPPORT - m_certVerifier = vmime::create (); + m_certVerifier = vmime::create (); #endif // VMIME_HAVE_TLS_SUPPORT m_socketFactory = platformDependant::getHandler()->getSocketFactory(); @@ -97,13 +97,13 @@ void service::setAuthenticator(ref auth) #if VMIME_HAVE_TLS_SUPPORT -void service::setCertificateVerifier(ref cv) +void service::setCertificateVerifier(ref cv) { m_certVerifier = cv; } -ref service::getCertificateVerifier() +ref service::getCertificateVerifier() { return m_certVerifier; } diff --git a/src/net/tls/TLSSession.cpp b/src/net/tls/TLSSession.cpp index fb84714c..caa63d0a 100644 --- a/src/net/tls/TLSSession.cpp +++ b/src/net/tls/TLSSession.cpp @@ -91,7 +91,7 @@ static TLSGlobal g_gnutlsGlobal; -TLSSession::TLSSession(ref cv) +TLSSession::TLSSession(ref cv) : m_certVerifier(cv) { int res; @@ -212,7 +212,7 @@ ref TLSSession::getSocket(ref sok) } -ref TLSSession::getCertificateVerifier() +ref TLSSession::getCertificateVerifier() { return m_certVerifier; } diff --git a/src/net/tls/TLSSocket.cpp b/src/net/tls/TLSSocket.cpp index ebf3214b..93066b98 100644 --- a/src/net/tls/TLSSocket.cpp +++ b/src/net/tls/TLSSocket.cpp @@ -29,7 +29,7 @@ #include "vmime/platformDependant.hpp" -#include "vmime/net/tls/X509Certificate.hpp" +#include "vmime/security/cert/X509Certificate.hpp" namespace vmime { @@ -185,7 +185,7 @@ void TLSSocket::handshake(ref toHandler) m_toHandler = NULL; // Verify server's certificate(s) - ref certs = getPeerCertificates(); + ref certs = getPeerCertificates(); if (certs == NULL) throw exceptions::tls_exception("No peer certificate."); @@ -280,7 +280,7 @@ ssize_t TLSSocket::gnutlsPullFunc } -ref TLSSocket::getPeerCertificates() +ref TLSSocket::getPeerCertificates() { unsigned int certCount = 0; const gnutls_datum* rawData = gnutls_certificate_get_peers @@ -304,7 +304,7 @@ ref TLSSocket::getPeerCertificates() if (res >= 1) { - std::vector > certs; + std::vector > certs; bool error = false; count = static_cast (res); @@ -321,8 +321,8 @@ ref TLSSocket::getPeerCertificates() gnutls_x509_crt_export(x509Certs[i], GNUTLS_X509_FMT_DER, data, &dataSize); - ref cert = - X509Certificate::import(data, dataSize); + ref cert = + security::cert::X509Certificate::import(data, dataSize); if (cert != NULL) certs.push_back(cert); @@ -339,7 +339,7 @@ ref TLSSocket::getPeerCertificates() if (error) return NULL; - return vmime::create (certs); + return vmime::create (certs); } delete [] x509Certs; diff --git a/src/net/tls/X509Certificate.cpp b/src/security/cert/X509Certificate.cpp similarity index 97% rename from src/net/tls/X509Certificate.cpp rename to src/security/cert/X509Certificate.cpp index cfb52a1d..a1310f51 100644 --- a/src/net/tls/X509Certificate.cpp +++ b/src/security/cert/X509Certificate.cpp @@ -26,12 +26,12 @@ #include -#include "vmime/net/tls/X509Certificate.hpp" +#include "vmime/security/cert/X509Certificate.hpp" namespace vmime { -namespace net { -namespace tls { +namespace security { +namespace cert { #ifndef VMIME_BUILDING_DOC @@ -267,7 +267,7 @@ const bool X509Certificate::equals(ref other) const } -} // tls -} // net +} // cert +} // security } // vmime diff --git a/src/net/tls/certificateChain.cpp b/src/security/cert/certificateChain.cpp similarity index 92% rename from src/net/tls/certificateChain.cpp rename to src/security/cert/certificateChain.cpp index 52855cc2..2ac25258 100644 --- a/src/net/tls/certificateChain.cpp +++ b/src/security/cert/certificateChain.cpp @@ -21,12 +21,12 @@ // the GNU General Public License cover the whole combination. // -#include "vmime/net/tls/certificateChain.hpp" +#include "vmime/security/cert/certificateChain.hpp" namespace vmime { -namespace net { -namespace tls { +namespace security { +namespace cert { certificateChain::certificateChain(const std::vector >& certs) @@ -47,7 +47,7 @@ ref certificateChain::getAt(const unsigned int index) } -} // tls -} // net +} // cert +} // security } // vmime diff --git a/src/net/tls/defaultCertificateVerifier.cpp b/src/security/cert/defaultCertificateVerifier.cpp similarity index 95% rename from src/net/tls/defaultCertificateVerifier.cpp rename to src/security/cert/defaultCertificateVerifier.cpp index de0c6e45..b125d3e4 100644 --- a/src/net/tls/defaultCertificateVerifier.cpp +++ b/src/security/cert/defaultCertificateVerifier.cpp @@ -21,16 +21,16 @@ // the GNU General Public License cover the whole combination. // -#include "vmime/net/tls/defaultCertificateVerifier.hpp" +#include "vmime/security/cert/defaultCertificateVerifier.hpp" -#include "vmime/net/tls/X509Certificate.hpp" +#include "vmime/security/cert/X509Certificate.hpp" #include "vmime/exception.hpp" namespace vmime { -namespace net { -namespace tls { +namespace security { +namespace cert { defaultCertificateVerifier::defaultCertificateVerifier() @@ -158,7 +158,7 @@ void defaultCertificateVerifier::setX509TrustedCerts } -} // tls -} // net +} // cert +} // security } // vmime diff --git a/vmime/net/service.hpp b/vmime/net/service.hpp index c96a8c4b..ec165462 100644 --- a/vmime/net/service.hpp +++ b/vmime/net/service.hpp @@ -36,7 +36,7 @@ #include "vmime/net/timeoutHandler.hpp" #if VMIME_HAVE_TLS_SUPPORT - #include "vmime/net/tls/certificateVerifier.hpp" + #include "vmime/security/cert/certificateVerifier.hpp" #endif // VMIME_HAVE_TLS_SUPPORT #include "vmime/utility/progressListener.hpp" @@ -139,12 +139,12 @@ public: /** Set the object responsible for verifying certificates when * using secured connections (TLS/SSL). */ - void setCertificateVerifier(ref cv); + void setCertificateVerifier(ref cv); /** Get the object responsible for verifying certificates when * using secured connections (TLS/SSL). */ - ref getCertificateVerifier(); + ref getCertificateVerifier(); #endif // VMIME_HAVE_TLS_SUPPORT @@ -197,7 +197,7 @@ private: ref m_auth; #if VMIME_HAVE_TLS_SUPPORT - ref m_certVerifier; + ref m_certVerifier; #endif // VMIME_HAVE_TLS_SUPPORT ref m_socketFactory; diff --git a/vmime/net/tls/TLSSession.hpp b/vmime/net/tls/TLSSession.hpp index e946c102..7927fba3 100644 --- a/vmime/net/tls/TLSSession.hpp +++ b/vmime/net/tls/TLSSession.hpp @@ -29,7 +29,7 @@ #include "vmime/net/tls/TLSSocket.hpp" -#include "vmime/net/tls/certificateVerifier.hpp" +#include "vmime/security/cert/certificateVerifier.hpp" namespace vmime { @@ -53,7 +53,7 @@ public: * sent by the server * @return a new TLS session */ - TLSSession(ref cv); + TLSSession(ref cv); /** Create a new socket that adds a TLS security layer around * an existing socket. You should create only one socket @@ -67,7 +67,7 @@ public: /** Get the object responsible for verifying certificates when * using secured connections (TLS/SSL). */ - ref getCertificateVerifier(); + ref getCertificateVerifier(); private: @@ -82,7 +82,7 @@ private: void* m_gnutlsSession; #endif // LIBGNUTLS_VERSION - ref m_certVerifier; + ref m_certVerifier; }; diff --git a/vmime/net/tls/TLSSocket.hpp b/vmime/net/tls/TLSSocket.hpp index 1fbe045a..8fb22990 100644 --- a/vmime/net/tls/TLSSocket.hpp +++ b/vmime/net/tls/TLSSocket.hpp @@ -30,7 +30,7 @@ #include "vmime/net/socket.hpp" #include "vmime/net/timeoutHandler.hpp" -#include "vmime/net/tls/certificateChain.hpp" +#include "vmime/security/cert/certificateChain.hpp" namespace vmime { @@ -75,7 +75,7 @@ public: * @return server certificate chain, or NULL if the handshake * has not been performed yet */ - ref getPeerCertificates(); + ref getPeerCertificates(); // Implementation of 'socket' diff --git a/vmime/net/tls/X509Certificate.hpp b/vmime/security/cert/X509Certificate.hpp similarity index 93% rename from vmime/net/tls/X509Certificate.hpp rename to vmime/security/cert/X509Certificate.hpp index 5edd4e46..45c50060 100644 --- a/vmime/net/tls/X509Certificate.hpp +++ b/vmime/security/cert/X509Certificate.hpp @@ -21,11 +21,11 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_NET_TLS_X509CERTIFICATE_HPP_INCLUDED -#define VMIME_NET_TLS_X509CERTIFICATE_HPP_INCLUDED +#ifndef VMIME_SECURITY_CERT_X509CERTIFICATE_HPP_INCLUDED +#define VMIME_SECURITY_CERT_X509CERTIFICATE_HPP_INCLUDED -#include "vmime/net/tls/certificate.hpp" +#include "vmime/security/cert/certificate.hpp" #include "vmime/utility/stream.hpp" @@ -34,8 +34,8 @@ namespace vmime { -namespace net { -namespace tls { +namespace security { +namespace cert { /** Identity certificate based on X.509 standard. @@ -149,10 +149,10 @@ private: }; -} // tls -} // net +} // cert +} // security } // vmime -#endif // VMIME_NET_TLS_X509CERTIFICATE_HPP_INCLUDED +#endif // VMIME_SECURITY_CERT_X509CERTIFICATE_HPP_INCLUDED diff --git a/vmime/net/tls/certificate.hpp b/vmime/security/cert/certificate.hpp similarity index 89% rename from vmime/net/tls/certificate.hpp rename to vmime/security/cert/certificate.hpp index c070484b..1c967f84 100644 --- a/vmime/net/tls/certificate.hpp +++ b/vmime/security/cert/certificate.hpp @@ -21,16 +21,16 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_NET_TLS_CERTIFICATE_HPP_INCLUDED -#define VMIME_NET_TLS_CERTIFICATE_HPP_INCLUDED +#ifndef VMIME_SECURITY_CERT_CERTIFICATE_HPP_INCLUDED +#define VMIME_SECURITY_CERT_CERTIFICATE_HPP_INCLUDED #include "vmime/types.hpp" namespace vmime { -namespace net { -namespace tls { +namespace security { +namespace cert { /** Identity certificate for a peer. @@ -68,10 +68,10 @@ public: }; -} // tls -} // net +} // cert +} // security } // vmime -#endif // VMIME_NET_TLS_CERTIFICATE_HPP_INCLUDED +#endif // VMIME_SECURITY_CERT_CERTIFICATE_HPP_INCLUDED diff --git a/vmime/net/tls/certificateChain.hpp b/vmime/security/cert/certificateChain.hpp similarity index 87% rename from vmime/net/tls/certificateChain.hpp rename to vmime/security/cert/certificateChain.hpp index 332e3f70..c9d2f1d0 100644 --- a/vmime/net/tls/certificateChain.hpp +++ b/vmime/security/cert/certificateChain.hpp @@ -21,18 +21,18 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_NET_TLS_CERTIFICATECHAIN_HPP_INCLUDED -#define VMIME_NET_TLS_CERTIFICATECHAIN_HPP_INCLUDED +#ifndef VMIME_SECURITY_CERT_CERTIFICATECHAIN_HPP_INCLUDED +#define VMIME_SECURITY_CERT_CERTIFICATECHAIN_HPP_INCLUDED #include "vmime/types.hpp" -#include "vmime/net/tls/certificate.hpp" +#include "vmime/security/cert/certificate.hpp" namespace vmime { -namespace net { -namespace tls { +namespace security { +namespace cert { /** An ordered list of certificates, from the subject certificate to @@ -70,10 +70,10 @@ protected: }; -} // tls -} // net +} // cert +} // security } // vmime -#endif // VMIME_NET_TLS_CERTIFICATECHAIN_HPP_INCLUDED +#endif // VMIME_SECURITY_CERT_CERTIFICATECHAIN_HPP_INCLUDED diff --git a/vmime/net/tls/certificateVerifier.hpp b/vmime/security/cert/certificateVerifier.hpp similarity index 83% rename from vmime/net/tls/certificateVerifier.hpp rename to vmime/security/cert/certificateVerifier.hpp index fd235b48..0b62fb89 100644 --- a/vmime/net/tls/certificateVerifier.hpp +++ b/vmime/security/cert/certificateVerifier.hpp @@ -21,18 +21,18 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_NET_TLS_CERTIFICATEVERIFIER_HPP_INCLUDED -#define VMIME_NET_TLS_CERTIFICATEVERIFIER_HPP_INCLUDED +#ifndef VMIME_SECURITY_CERT_CERTIFICATEVERIFIER_HPP_INCLUDED +#define VMIME_SECURITY_CERT_CERTIFICATEVERIFIER_HPP_INCLUDED #include "vmime/types.hpp" -#include "vmime/net/tls/certificateChain.hpp" +#include "vmime/security/cert/certificateChain.hpp" namespace vmime { -namespace net { -namespace tls { +namespace security { +namespace cert { /** Verify that a certificate path issued by a server can be trusted. @@ -51,10 +51,10 @@ public: }; -} // tls -} // net +} // cert +} // security } // vmime -#endif // VMIME_NET_TLS_CERTIFICATEVERIFIER_HPP_INCLUDED +#endif // VMIME_SECURITY_CERT_CERTIFICATEVERIFIER_HPP_INCLUDED diff --git a/vmime/net/tls/defaultCertificateVerifier.hpp b/vmime/security/cert/defaultCertificateVerifier.hpp similarity index 86% rename from vmime/net/tls/defaultCertificateVerifier.hpp rename to vmime/security/cert/defaultCertificateVerifier.hpp index 3713fd21..b4df6e8c 100644 --- a/vmime/net/tls/defaultCertificateVerifier.hpp +++ b/vmime/security/cert/defaultCertificateVerifier.hpp @@ -21,16 +21,16 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_NET_TLS_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED -#define VMIME_NET_TLS_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED +#ifndef VMIME_SECURITY_CERT_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED +#define VMIME_SECURITY_CERT_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED -#include "vmime/net/tls/certificateVerifier.hpp" +#include "vmime/security/cert/certificateVerifier.hpp" namespace vmime { -namespace net { -namespace tls { +namespace security { +namespace cert { class X509Certificate; @@ -79,10 +79,10 @@ private: }; -} // tls -} // net +} // cert +} // security } // vmime -#endif // VMIME_NET_TLS_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED +#endif // VMIME_SECURITY_CERT_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED diff --git a/vmime/vmime.hpp b/vmime/vmime.hpp index 337f91f2..36b9e0e3 100644 --- a/vmime/vmime.hpp +++ b/vmime/vmime.hpp @@ -124,13 +124,13 @@ // Net/TLS #if VMIME_HAVE_TLS_SUPPORT - #include "vmime/net/tls/certificate.hpp" - #include "vmime/net/tls/certificateChain.hpp" - #include "vmime/net/tls/certificateVerifier.hpp" + #include "vmime/security/cert/certificate.hpp" + #include "vmime/security/cert/certificateChain.hpp" + #include "vmime/security/cert/certificateVerifier.hpp" - #include "vmime/net/tls/X509Certificate.hpp" + #include "vmime/security/cert/X509Certificate.hpp" - #include "vmime/net/tls/defaultCertificateVerifier.hpp" + #include "vmime/security/cert/defaultCertificateVerifier.hpp" #include "vmime/net/tls/TLSSession.hpp" #endif // VMIME_HAVE_TLS_SUPPORT