Moved certificate code into 'vmime::net::security::cert' namespace.

This commit is contained in:
Vincent Richard 2005-10-30 15:02:39 +00:00
parent c241f071d2
commit 4522121196
17 changed files with 94 additions and 94 deletions

View File

@ -218,11 +218,11 @@ libvmime_messaging_sources = [
libvmime_net_tls_sources = [ libvmime_net_tls_sources = [
'net/tls/TLSSession.cpp', 'net/tls/TLSSession.hpp', 'net/tls/TLSSession.cpp', 'net/tls/TLSSession.hpp',
'net/tls/TLSSocket.cpp', 'net/tls/TLSSocket.hpp', 'net/tls/TLSSocket.cpp', 'net/tls/TLSSocket.hpp',
'net/tls/certificateChain.cpp', 'net/tls/certificateChain.hpp', 'security/cert/certificateChain.cpp', 'security/cert/certificateChain.hpp',
'net/tls/certificateVerifier.hpp', 'security/cert/certificateVerifier.hpp',
'net/tls/defaultCertificateVerifier.cpp', 'net/tls/defaultCertificateVerifier.hpp', 'security/cert/defaultCertificateVerifier.cpp', 'security/cert/defaultCertificateVerifier.hpp',
'net/tls/certificate.hpp', 'security/cert/certificate.hpp',
'net/tls/X509Certificate.cpp', 'net/tls/X509Certificate.hpp' 'security/cert/X509Certificate.cpp', 'security/cert/X509Certificate.hpp'
] ]
libvmime_messaging_proto_sources = [ libvmime_messaging_proto_sources = [

View File

@ -101,11 +101,11 @@ private:
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
// Certificate verifier (TLS/SSL) // Certificate verifier (TLS/SSL)
class interactiveCertificateVerifier : public vmime::net::tls::defaultCertificateVerifier class interactiveCertificateVerifier : public vmime::security::cert::defaultCertificateVerifier
{ {
public: public:
void verify(vmime::ref <vmime::net::tls::certificateChain> chain) void verify(vmime::ref <vmime::security::cert::certificateChain> chain)
{ {
try try
{ {
@ -116,7 +116,7 @@ public:
catch (vmime::exceptions::certificate_verification_exception&) catch (vmime::exceptions::certificate_verification_exception&)
{ {
// Obtain subject's certificate // Obtain subject's certificate
vmime::ref <vmime::net::tls::certificate> cert = chain->getAt(0); vmime::ref <vmime::security::cert::certificate> cert = chain->getAt(0);
std::cout << std::endl; std::cout << std::endl;
std::cout << "Server sent a '" << cert->getType() << "'" << " certificate." << std::endl; std::cout << "Server sent a '" << cert->getType() << "'" << " certificate." << std::endl;
@ -133,7 +133,7 @@ public:
if (cert->getType() == "X.509") if (cert->getType() == "X.509")
{ {
m_trustedCerts.push_back(cert.dynamicCast m_trustedCerts.push_back(cert.dynamicCast
<vmime::net::tls::X509Certificate>()); <vmime::security::cert::X509Certificate>());
} }
return; return;
@ -146,11 +146,11 @@ public:
private: private:
static std::vector <vmime::ref <vmime::net::tls::X509Certificate> > m_trustedCerts; static std::vector <vmime::ref <vmime::security::cert::X509Certificate> > m_trustedCerts;
}; };
std::vector <vmime::ref <vmime::net::tls::X509Certificate> > std::vector <vmime::ref <vmime::security::cert::X509Certificate> >
interactiveCertificateVerifier::m_trustedCerts; interactiveCertificateVerifier::m_trustedCerts;
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT

View File

@ -29,7 +29,7 @@
#endif // VMIME_HAVE_SASL_SUPPORT #endif // VMIME_HAVE_SASL_SUPPORT
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
#include "vmime/net/tls/defaultCertificateVerifier.hpp" #include "vmime/security/cert/defaultCertificateVerifier.hpp"
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT
@ -53,7 +53,7 @@ service::service(ref <session> sess, const serviceInfos& /* infos */,
} }
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
m_certVerifier = vmime::create <tls::defaultCertificateVerifier>(); m_certVerifier = vmime::create <security::cert::defaultCertificateVerifier>();
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT
m_socketFactory = platformDependant::getHandler()->getSocketFactory(); m_socketFactory = platformDependant::getHandler()->getSocketFactory();
@ -97,13 +97,13 @@ void service::setAuthenticator(ref <security::authenticator> auth)
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
void service::setCertificateVerifier(ref <tls::certificateVerifier> cv) void service::setCertificateVerifier(ref <security::cert::certificateVerifier> cv)
{ {
m_certVerifier = cv; m_certVerifier = cv;
} }
ref <tls::certificateVerifier> service::getCertificateVerifier() ref <security::cert::certificateVerifier> service::getCertificateVerifier()
{ {
return m_certVerifier; return m_certVerifier;
} }

View File

@ -91,7 +91,7 @@ static TLSGlobal g_gnutlsGlobal;
TLSSession::TLSSession(ref <certificateVerifier> cv) TLSSession::TLSSession(ref <security::cert::certificateVerifier> cv)
: m_certVerifier(cv) : m_certVerifier(cv)
{ {
int res; int res;
@ -212,7 +212,7 @@ ref <TLSSocket> TLSSession::getSocket(ref <socket> sok)
} }
ref <tls::certificateVerifier> TLSSession::getCertificateVerifier() ref <security::cert::certificateVerifier> TLSSession::getCertificateVerifier()
{ {
return m_certVerifier; return m_certVerifier;
} }

View File

@ -29,7 +29,7 @@
#include "vmime/platformDependant.hpp" #include "vmime/platformDependant.hpp"
#include "vmime/net/tls/X509Certificate.hpp" #include "vmime/security/cert/X509Certificate.hpp"
namespace vmime { namespace vmime {
@ -185,7 +185,7 @@ void TLSSocket::handshake(ref <timeoutHandler> toHandler)
m_toHandler = NULL; m_toHandler = NULL;
// Verify server's certificate(s) // Verify server's certificate(s)
ref <certificateChain> certs = getPeerCertificates(); ref <security::cert::certificateChain> certs = getPeerCertificates();
if (certs == NULL) if (certs == NULL)
throw exceptions::tls_exception("No peer certificate."); throw exceptions::tls_exception("No peer certificate.");
@ -280,7 +280,7 @@ ssize_t TLSSocket::gnutlsPullFunc
} }
ref <certificateChain> TLSSocket::getPeerCertificates() ref <security::cert::certificateChain> TLSSocket::getPeerCertificates()
{ {
unsigned int certCount = 0; unsigned int certCount = 0;
const gnutls_datum* rawData = gnutls_certificate_get_peers const gnutls_datum* rawData = gnutls_certificate_get_peers
@ -304,7 +304,7 @@ ref <certificateChain> TLSSocket::getPeerCertificates()
if (res >= 1) if (res >= 1)
{ {
std::vector <ref <certificate> > certs; std::vector <ref <security::cert::certificate> > certs;
bool error = false; bool error = false;
count = static_cast <unsigned int>(res); count = static_cast <unsigned int>(res);
@ -321,8 +321,8 @@ ref <certificateChain> TLSSocket::getPeerCertificates()
gnutls_x509_crt_export(x509Certs[i], gnutls_x509_crt_export(x509Certs[i],
GNUTLS_X509_FMT_DER, data, &dataSize); GNUTLS_X509_FMT_DER, data, &dataSize);
ref <X509Certificate> cert = ref <security::cert::X509Certificate> cert =
X509Certificate::import(data, dataSize); security::cert::X509Certificate::import(data, dataSize);
if (cert != NULL) if (cert != NULL)
certs.push_back(cert); certs.push_back(cert);
@ -339,7 +339,7 @@ ref <certificateChain> TLSSocket::getPeerCertificates()
if (error) if (error)
return NULL; return NULL;
return vmime::create <certificateChain>(certs); return vmime::create <security::cert::certificateChain>(certs);
} }
delete [] x509Certs; delete [] x509Certs;

View File

@ -26,12 +26,12 @@
#include <ctime> #include <ctime>
#include "vmime/net/tls/X509Certificate.hpp" #include "vmime/security/cert/X509Certificate.hpp"
namespace vmime { namespace vmime {
namespace net { namespace security {
namespace tls { namespace cert {
#ifndef VMIME_BUILDING_DOC #ifndef VMIME_BUILDING_DOC
@ -267,7 +267,7 @@ const bool X509Certificate::equals(ref <const certificate> other) const
} }
} // tls } // cert
} // net } // security
} // vmime } // vmime

View File

@ -21,12 +21,12 @@
// the GNU General Public License cover the whole combination. // the GNU General Public License cover the whole combination.
// //
#include "vmime/net/tls/certificateChain.hpp" #include "vmime/security/cert/certificateChain.hpp"
namespace vmime { namespace vmime {
namespace net { namespace security {
namespace tls { namespace cert {
certificateChain::certificateChain(const std::vector <ref <certificate> >& certs) certificateChain::certificateChain(const std::vector <ref <certificate> >& certs)
@ -47,7 +47,7 @@ ref <certificate> certificateChain::getAt(const unsigned int index)
} }
} // tls } // cert
} // net } // security
} // vmime } // vmime

View File

@ -21,16 +21,16 @@
// the GNU General Public License cover the whole combination. // 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" #include "vmime/exception.hpp"
namespace vmime { namespace vmime {
namespace net { namespace security {
namespace tls { namespace cert {
defaultCertificateVerifier::defaultCertificateVerifier() defaultCertificateVerifier::defaultCertificateVerifier()
@ -158,7 +158,7 @@ void defaultCertificateVerifier::setX509TrustedCerts
} }
} // tls } // cert
} // net } // security
} // vmime } // vmime

View File

@ -36,7 +36,7 @@
#include "vmime/net/timeoutHandler.hpp" #include "vmime/net/timeoutHandler.hpp"
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
#include "vmime/net/tls/certificateVerifier.hpp" #include "vmime/security/cert/certificateVerifier.hpp"
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT
#include "vmime/utility/progressListener.hpp" #include "vmime/utility/progressListener.hpp"
@ -139,12 +139,12 @@ public:
/** Set the object responsible for verifying certificates when /** Set the object responsible for verifying certificates when
* using secured connections (TLS/SSL). * using secured connections (TLS/SSL).
*/ */
void setCertificateVerifier(ref <tls::certificateVerifier> cv); void setCertificateVerifier(ref <security::cert::certificateVerifier> cv);
/** Get the object responsible for verifying certificates when /** Get the object responsible for verifying certificates when
* using secured connections (TLS/SSL). * using secured connections (TLS/SSL).
*/ */
ref <tls::certificateVerifier> getCertificateVerifier(); ref <security::cert::certificateVerifier> getCertificateVerifier();
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT
@ -197,7 +197,7 @@ private:
ref <security::authenticator> m_auth; ref <security::authenticator> m_auth;
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
ref <tls::certificateVerifier> m_certVerifier; ref <security::cert::certificateVerifier> m_certVerifier;
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT
ref <socketFactory> m_socketFactory; ref <socketFactory> m_socketFactory;

View File

@ -29,7 +29,7 @@
#include "vmime/net/tls/TLSSocket.hpp" #include "vmime/net/tls/TLSSocket.hpp"
#include "vmime/net/tls/certificateVerifier.hpp" #include "vmime/security/cert/certificateVerifier.hpp"
namespace vmime { namespace vmime {
@ -53,7 +53,7 @@ public:
* sent by the server * sent by the server
* @return a new TLS session * @return a new TLS session
*/ */
TLSSession(ref <certificateVerifier> cv); TLSSession(ref <security::cert::certificateVerifier> cv);
/** Create a new socket that adds a TLS security layer around /** Create a new socket that adds a TLS security layer around
* an existing socket. You should create only one socket * an existing socket. You should create only one socket
@ -67,7 +67,7 @@ public:
/** Get the object responsible for verifying certificates when /** Get the object responsible for verifying certificates when
* using secured connections (TLS/SSL). * using secured connections (TLS/SSL).
*/ */
ref <tls::certificateVerifier> getCertificateVerifier(); ref <security::cert::certificateVerifier> getCertificateVerifier();
private: private:
@ -82,7 +82,7 @@ private:
void* m_gnutlsSession; void* m_gnutlsSession;
#endif // LIBGNUTLS_VERSION #endif // LIBGNUTLS_VERSION
ref <certificateVerifier> m_certVerifier; ref <security::cert::certificateVerifier> m_certVerifier;
}; };

View File

@ -30,7 +30,7 @@
#include "vmime/net/socket.hpp" #include "vmime/net/socket.hpp"
#include "vmime/net/timeoutHandler.hpp" #include "vmime/net/timeoutHandler.hpp"
#include "vmime/net/tls/certificateChain.hpp" #include "vmime/security/cert/certificateChain.hpp"
namespace vmime { namespace vmime {
@ -75,7 +75,7 @@ public:
* @return server certificate chain, or NULL if the handshake * @return server certificate chain, or NULL if the handshake
* has not been performed yet * has not been performed yet
*/ */
ref <certificateChain> getPeerCertificates(); ref <security::cert::certificateChain> getPeerCertificates();
// Implementation of 'socket' // Implementation of 'socket'

View File

@ -21,11 +21,11 @@
// the GNU General Public License cover the whole combination. // the GNU General Public License cover the whole combination.
// //
#ifndef VMIME_NET_TLS_X509CERTIFICATE_HPP_INCLUDED #ifndef VMIME_SECURITY_CERT_X509CERTIFICATE_HPP_INCLUDED
#define VMIME_NET_TLS_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" #include "vmime/utility/stream.hpp"
@ -34,8 +34,8 @@
namespace vmime { namespace vmime {
namespace net { namespace security {
namespace tls { namespace cert {
/** Identity certificate based on X.509 standard. /** Identity certificate based on X.509 standard.
@ -149,10 +149,10 @@ private:
}; };
} // tls } // cert
} // net } // security
} // vmime } // vmime
#endif // VMIME_NET_TLS_X509CERTIFICATE_HPP_INCLUDED #endif // VMIME_SECURITY_CERT_X509CERTIFICATE_HPP_INCLUDED

View File

@ -21,16 +21,16 @@
// the GNU General Public License cover the whole combination. // the GNU General Public License cover the whole combination.
// //
#ifndef VMIME_NET_TLS_CERTIFICATE_HPP_INCLUDED #ifndef VMIME_SECURITY_CERT_CERTIFICATE_HPP_INCLUDED
#define VMIME_NET_TLS_CERTIFICATE_HPP_INCLUDED #define VMIME_SECURITY_CERT_CERTIFICATE_HPP_INCLUDED
#include "vmime/types.hpp" #include "vmime/types.hpp"
namespace vmime { namespace vmime {
namespace net { namespace security {
namespace tls { namespace cert {
/** Identity certificate for a peer. /** Identity certificate for a peer.
@ -68,10 +68,10 @@ public:
}; };
} // tls } // cert
} // net } // security
} // vmime } // vmime
#endif // VMIME_NET_TLS_CERTIFICATE_HPP_INCLUDED #endif // VMIME_SECURITY_CERT_CERTIFICATE_HPP_INCLUDED

View File

@ -21,18 +21,18 @@
// the GNU General Public License cover the whole combination. // the GNU General Public License cover the whole combination.
// //
#ifndef VMIME_NET_TLS_CERTIFICATECHAIN_HPP_INCLUDED #ifndef VMIME_SECURITY_CERT_CERTIFICATECHAIN_HPP_INCLUDED
#define VMIME_NET_TLS_CERTIFICATECHAIN_HPP_INCLUDED #define VMIME_SECURITY_CERT_CERTIFICATECHAIN_HPP_INCLUDED
#include "vmime/types.hpp" #include "vmime/types.hpp"
#include "vmime/net/tls/certificate.hpp" #include "vmime/security/cert/certificate.hpp"
namespace vmime { namespace vmime {
namespace net { namespace security {
namespace tls { namespace cert {
/** An ordered list of certificates, from the subject certificate to /** An ordered list of certificates, from the subject certificate to
@ -70,10 +70,10 @@ protected:
}; };
} // tls } // cert
} // net } // security
} // vmime } // vmime
#endif // VMIME_NET_TLS_CERTIFICATECHAIN_HPP_INCLUDED #endif // VMIME_SECURITY_CERT_CERTIFICATECHAIN_HPP_INCLUDED

View File

@ -21,18 +21,18 @@
// the GNU General Public License cover the whole combination. // the GNU General Public License cover the whole combination.
// //
#ifndef VMIME_NET_TLS_CERTIFICATEVERIFIER_HPP_INCLUDED #ifndef VMIME_SECURITY_CERT_CERTIFICATEVERIFIER_HPP_INCLUDED
#define VMIME_NET_TLS_CERTIFICATEVERIFIER_HPP_INCLUDED #define VMIME_SECURITY_CERT_CERTIFICATEVERIFIER_HPP_INCLUDED
#include "vmime/types.hpp" #include "vmime/types.hpp"
#include "vmime/net/tls/certificateChain.hpp" #include "vmime/security/cert/certificateChain.hpp"
namespace vmime { namespace vmime {
namespace net { namespace security {
namespace tls { namespace cert {
/** Verify that a certificate path issued by a server can be trusted. /** Verify that a certificate path issued by a server can be trusted.
@ -51,10 +51,10 @@ public:
}; };
} // tls } // cert
} // net } // security
} // vmime } // vmime
#endif // VMIME_NET_TLS_CERTIFICATEVERIFIER_HPP_INCLUDED #endif // VMIME_SECURITY_CERT_CERTIFICATEVERIFIER_HPP_INCLUDED

View File

@ -21,16 +21,16 @@
// the GNU General Public License cover the whole combination. // the GNU General Public License cover the whole combination.
// //
#ifndef VMIME_NET_TLS_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED #ifndef VMIME_SECURITY_CERT_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED
#define VMIME_NET_TLS_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 vmime {
namespace net { namespace security {
namespace tls { namespace cert {
class X509Certificate; class X509Certificate;
@ -79,10 +79,10 @@ private:
}; };
} // tls } // cert
} // net } // security
} // vmime } // vmime
#endif // VMIME_NET_TLS_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED #endif // VMIME_SECURITY_CERT_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED

View File

@ -124,13 +124,13 @@
// Net/TLS // Net/TLS
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
#include "vmime/net/tls/certificate.hpp" #include "vmime/security/cert/certificate.hpp"
#include "vmime/net/tls/certificateChain.hpp" #include "vmime/security/cert/certificateChain.hpp"
#include "vmime/net/tls/certificateVerifier.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" #include "vmime/net/tls/TLSSession.hpp"
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT