Moved certificate code into 'vmime::net::security::cert' namespace.
This commit is contained in:
parent
c241f071d2
commit
4522121196
10
SConstruct
10
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 = [
|
||||
|
@ -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 <vmime::net::tls::certificateChain> chain)
|
||||
void verify(vmime::ref <vmime::security::cert::certificateChain> chain)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -116,7 +116,7 @@ public:
|
||||
catch (vmime::exceptions::certificate_verification_exception&)
|
||||
{
|
||||
// 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 << "Server sent a '" << cert->getType() << "'" << " certificate." << std::endl;
|
||||
@ -133,7 +133,7 @@ public:
|
||||
if (cert->getType() == "X.509")
|
||||
{
|
||||
m_trustedCerts.push_back(cert.dynamicCast
|
||||
<vmime::net::tls::X509Certificate>());
|
||||
<vmime::security::cert::X509Certificate>());
|
||||
}
|
||||
|
||||
return;
|
||||
@ -146,11 +146,11 @@ public:
|
||||
|
||||
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;
|
||||
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
@ -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 <session> sess, const serviceInfos& /* infos */,
|
||||
}
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
m_certVerifier = vmime::create <tls::defaultCertificateVerifier>();
|
||||
m_certVerifier = vmime::create <security::cert::defaultCertificateVerifier>();
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
m_socketFactory = platformDependant::getHandler()->getSocketFactory();
|
||||
@ -97,13 +97,13 @@ void service::setAuthenticator(ref <security::authenticator> auth)
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
void service::setCertificateVerifier(ref <tls::certificateVerifier> cv)
|
||||
void service::setCertificateVerifier(ref <security::cert::certificateVerifier> cv)
|
||||
{
|
||||
m_certVerifier = cv;
|
||||
}
|
||||
|
||||
|
||||
ref <tls::certificateVerifier> service::getCertificateVerifier()
|
||||
ref <security::cert::certificateVerifier> service::getCertificateVerifier()
|
||||
{
|
||||
return m_certVerifier;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ static TLSGlobal g_gnutlsGlobal;
|
||||
|
||||
|
||||
|
||||
TLSSession::TLSSession(ref <certificateVerifier> cv)
|
||||
TLSSession::TLSSession(ref <security::cert::certificateVerifier> cv)
|
||||
: m_certVerifier(cv)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -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 <timeoutHandler> toHandler)
|
||||
m_toHandler = NULL;
|
||||
|
||||
// Verify server's certificate(s)
|
||||
ref <certificateChain> certs = getPeerCertificates();
|
||||
ref <security::cert::certificateChain> certs = getPeerCertificates();
|
||||
|
||||
if (certs == NULL)
|
||||
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;
|
||||
const gnutls_datum* rawData = gnutls_certificate_get_peers
|
||||
@ -304,7 +304,7 @@ ref <certificateChain> TLSSocket::getPeerCertificates()
|
||||
|
||||
if (res >= 1)
|
||||
{
|
||||
std::vector <ref <certificate> > certs;
|
||||
std::vector <ref <security::cert::certificate> > certs;
|
||||
bool error = false;
|
||||
|
||||
count = static_cast <unsigned int>(res);
|
||||
@ -321,8 +321,8 @@ ref <certificateChain> TLSSocket::getPeerCertificates()
|
||||
gnutls_x509_crt_export(x509Certs[i],
|
||||
GNUTLS_X509_FMT_DER, data, &dataSize);
|
||||
|
||||
ref <X509Certificate> cert =
|
||||
X509Certificate::import(data, dataSize);
|
||||
ref <security::cert::X509Certificate> cert =
|
||||
security::cert::X509Certificate::import(data, dataSize);
|
||||
|
||||
if (cert != NULL)
|
||||
certs.push_back(cert);
|
||||
@ -339,7 +339,7 @@ ref <certificateChain> TLSSocket::getPeerCertificates()
|
||||
if (error)
|
||||
return NULL;
|
||||
|
||||
return vmime::create <certificateChain>(certs);
|
||||
return vmime::create <security::cert::certificateChain>(certs);
|
||||
}
|
||||
|
||||
delete [] x509Certs;
|
||||
|
@ -26,12 +26,12 @@
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#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 <const certificate> other) const
|
||||
}
|
||||
|
||||
|
||||
} // tls
|
||||
} // net
|
||||
} // cert
|
||||
} // security
|
||||
} // vmime
|
||||
|
@ -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 <ref <certificate> >& certs)
|
||||
@ -47,7 +47,7 @@ ref <certificate> certificateChain::getAt(const unsigned int index)
|
||||
}
|
||||
|
||||
|
||||
} // tls
|
||||
} // net
|
||||
} // cert
|
||||
} // security
|
||||
} // vmime
|
||||
|
@ -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
|
||||
|
@ -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 <tls::certificateVerifier> cv);
|
||||
void setCertificateVerifier(ref <security::cert::certificateVerifier> cv);
|
||||
|
||||
/** Get the object responsible for verifying certificates when
|
||||
* using secured connections (TLS/SSL).
|
||||
*/
|
||||
ref <tls::certificateVerifier> getCertificateVerifier();
|
||||
ref <security::cert::certificateVerifier> getCertificateVerifier();
|
||||
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
@ -197,7 +197,7 @@ private:
|
||||
ref <security::authenticator> m_auth;
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
ref <tls::certificateVerifier> m_certVerifier;
|
||||
ref <security::cert::certificateVerifier> m_certVerifier;
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
ref <socketFactory> m_socketFactory;
|
||||
|
@ -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 <certificateVerifier> cv);
|
||||
TLSSession(ref <security::cert::certificateVerifier> 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 <tls::certificateVerifier> getCertificateVerifier();
|
||||
ref <security::cert::certificateVerifier> getCertificateVerifier();
|
||||
|
||||
private:
|
||||
|
||||
@ -82,7 +82,7 @@ private:
|
||||
void* m_gnutlsSession;
|
||||
#endif // LIBGNUTLS_VERSION
|
||||
|
||||
ref <certificateVerifier> m_certVerifier;
|
||||
ref <security::cert::certificateVerifier> m_certVerifier;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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 <certificateChain> getPeerCertificates();
|
||||
ref <security::cert::certificateChain> getPeerCertificates();
|
||||
|
||||
|
||||
// Implementation of 'socket'
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user