aboutsummaryrefslogtreecommitdiffstats
path: root/src/security/cert
diff options
context:
space:
mode:
Diffstat (limited to 'src/security/cert')
-rw-r--r--src/security/cert/certificateChain.cpp4
-rw-r--r--src/security/cert/defaultCertificateVerifier.cpp32
-rw-r--r--src/security/cert/gnutls/X509Certificate_GnuTLS.cpp28
-rw-r--r--src/security/cert/openssl/X509Certificate_OpenSSL.cpp32
4 files changed, 48 insertions, 48 deletions
diff --git a/src/security/cert/certificateChain.cpp b/src/security/cert/certificateChain.cpp
index ab12453e..3cb4e360 100644
--- a/src/security/cert/certificateChain.cpp
+++ b/src/security/cert/certificateChain.cpp
@@ -29,7 +29,7 @@ namespace security {
namespace cert {
-certificateChain::certificateChain(const std::vector <ref <certificate> >& certs)
+certificateChain::certificateChain(const std::vector <shared_ptr <certificate> >& certs)
: m_certs(certs)
{
}
@@ -41,7 +41,7 @@ unsigned int certificateChain::getCount() const
}
-ref <certificate> certificateChain::getAt(const unsigned int index)
+shared_ptr <certificate> certificateChain::getAt(const unsigned int index)
{
return m_certs[index];
}
diff --git a/src/security/cert/defaultCertificateVerifier.cpp b/src/security/cert/defaultCertificateVerifier.cpp
index bb185f36..1a95b353 100644
--- a/src/security/cert/defaultCertificateVerifier.cpp
+++ b/src/security/cert/defaultCertificateVerifier.cpp
@@ -55,7 +55,7 @@ defaultCertificateVerifier::defaultCertificateVerifier(const defaultCertificateV
void defaultCertificateVerifier::verify
- (ref <certificateChain> chain, const string& hostname)
+ (shared_ptr <certificateChain> chain, const string& hostname)
{
if (chain->getCount() == 0)
return;
@@ -70,7 +70,7 @@ void defaultCertificateVerifier::verify
void defaultCertificateVerifier::verifyX509
- (ref <certificateChain> chain, const string& hostname)
+ (shared_ptr <certificateChain> chain, const string& hostname)
{
// For every certificate in the chain, verify that the certificate
// has been issued by the next certificate in the chain
@@ -78,11 +78,11 @@ void defaultCertificateVerifier::verifyX509
{
for (unsigned int i = 0 ; i < chain->getCount() - 1 ; ++i)
{
- ref <X509Certificate> cert =
- chain->getAt(i).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> cert =
+ dynamicCast <X509Certificate>(chain->getAt(i));
- ref <X509Certificate> next =
- chain->getAt(i + 1).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> next =
+ dynamicCast <X509Certificate>(chain->getAt(i + 1));
if (!cert->checkIssuer(next))
{
@@ -98,8 +98,8 @@ void defaultCertificateVerifier::verifyX509
for (unsigned int i = 0 ; i < chain->getCount() ; ++i)
{
- ref <X509Certificate> cert =
- chain->getAt(i).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> cert =
+ dynamicCast <X509Certificate>(chain->getAt(i));
const datetime begin = cert->getActivationDate();
const datetime end = cert->getExpirationDate();
@@ -115,14 +115,14 @@ void defaultCertificateVerifier::verifyX509
// -- First, verify that the the last certificate in the chain was
// -- issued by a third-party that we trust
- ref <X509Certificate> lastCert =
- chain->getAt(chain->getCount() - 1).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> lastCert =
+ dynamicCast <X509Certificate>(chain->getAt(chain->getCount() - 1));
bool trusted = false;
for (unsigned int i = 0 ; !trusted && i < m_x509RootCAs.size() ; ++i)
{
- ref <X509Certificate> rootCa = m_x509RootCAs[i];
+ shared_ptr <X509Certificate> rootCa = m_x509RootCAs[i];
if (lastCert->verify(rootCa))
trusted = true;
@@ -131,12 +131,12 @@ void defaultCertificateVerifier::verifyX509
// -- Next, if the issuer certificate cannot be verified against
// -- root CAs, compare the subject's certificate against the
// -- trusted certificates
- ref <X509Certificate> firstCert =
- chain->getAt(0).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> firstCert =
+ dynamicCast <X509Certificate>(chain->getAt(0));
for (unsigned int i = 0 ; !trusted && i < m_x509TrustedCerts.size() ; ++i)
{
- ref <X509Certificate> cert = m_x509TrustedCerts[i];
+ shared_ptr <X509Certificate> cert = m_x509TrustedCerts[i];
if (firstCert->equals(cert))
trusted = true;
@@ -158,14 +158,14 @@ void defaultCertificateVerifier::verifyX509
void defaultCertificateVerifier::setX509RootCAs
- (const std::vector <ref <X509Certificate> >& caCerts)
+ (const std::vector <shared_ptr <X509Certificate> >& caCerts)
{
m_x509RootCAs = caCerts;
}
void defaultCertificateVerifier::setX509TrustedCerts
- (const std::vector <ref <X509Certificate> >& trustedCerts)
+ (const std::vector <shared_ptr <X509Certificate> >& trustedCerts)
{
m_x509TrustedCerts = trustedCerts;
}
diff --git a/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp b/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp
index 96137844..327ddefa 100644
--- a/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp
+++ b/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp
@@ -89,7 +89,7 @@ void* X509Certificate_GnuTLS::getInternalData()
// static
-ref <X509Certificate> X509Certificate::import(utility::inputStream& is)
+shared_ptr <X509Certificate> X509Certificate::import(utility::inputStream& is)
{
byteArray bytes;
utility::stream::value_type chunk[4096];
@@ -105,7 +105,7 @@ ref <X509Certificate> X509Certificate::import(utility::inputStream& is)
// static
-ref <X509Certificate> X509Certificate::import
+shared_ptr <X509Certificate> X509Certificate::import
(const byte_t* data, const size_t length)
{
gnutls_datum buffer;
@@ -113,18 +113,18 @@ ref <X509Certificate> X509Certificate::import
buffer.size = static_cast <unsigned int>(length);
// Try DER format
- ref <X509Certificate_GnuTLS> derCert = vmime::create <X509Certificate_GnuTLS>();
+ shared_ptr <X509Certificate_GnuTLS> derCert = make_shared <X509Certificate_GnuTLS>();
if (gnutls_x509_crt_import(derCert->m_data->cert, &buffer, GNUTLS_X509_FMT_DER) >= 0)
return derCert;
// Try PEM format
- ref <X509Certificate_GnuTLS> pemCert = vmime::create <X509Certificate_GnuTLS>();
+ shared_ptr <X509Certificate_GnuTLS> pemCert = make_shared <X509Certificate_GnuTLS>();
if (gnutls_x509_crt_import(pemCert->m_data->cert, &buffer, GNUTLS_X509_FMT_PEM) >= 0)
return pemCert;
- return NULL;
+ return null;
}
@@ -161,20 +161,20 @@ const byteArray X509Certificate_GnuTLS::getSerialNumber() const
}
-bool X509Certificate_GnuTLS::checkIssuer(ref <const X509Certificate> issuer_) const
+bool X509Certificate_GnuTLS::checkIssuer(shared_ptr <const X509Certificate> issuer_) const
{
- ref <const X509Certificate_GnuTLS> issuer =
- issuer_.dynamicCast <const X509Certificate_GnuTLS>();
+ shared_ptr <const X509Certificate_GnuTLS> issuer =
+ dynamicCast <const X509Certificate_GnuTLS>(issuer_);
return (gnutls_x509_crt_check_issuer
(m_data->cert, issuer->m_data->cert) >= 1);
}
-bool X509Certificate_GnuTLS::verify(ref <const X509Certificate> caCert_) const
+bool X509Certificate_GnuTLS::verify(shared_ptr <const X509Certificate> caCert_) const
{
- ref <const X509Certificate_GnuTLS> caCert =
- caCert_.dynamicCast <const X509Certificate_GnuTLS>();
+ shared_ptr <const X509Certificate_GnuTLS> caCert =
+ dynamicCast <const X509Certificate_GnuTLS>(caCert_);
unsigned int verify = 0;
@@ -267,10 +267,10 @@ int X509Certificate_GnuTLS::getVersion() const
}
-bool X509Certificate_GnuTLS::equals(ref <const certificate> other) const
+bool X509Certificate_GnuTLS::equals(shared_ptr <const certificate> other) const
{
- ref <const X509Certificate_GnuTLS> otherX509 =
- other.dynamicCast <const X509Certificate_GnuTLS>();
+ shared_ptr <const X509Certificate_GnuTLS> otherX509 =
+ dynamicCast <const X509Certificate_GnuTLS>(other);
if (!otherX509)
return false;
diff --git a/src/security/cert/openssl/X509Certificate_OpenSSL.cpp b/src/security/cert/openssl/X509Certificate_OpenSSL.cpp
index 8c18583b..8c7174a0 100644
--- a/src/security/cert/openssl/X509Certificate_OpenSSL.cpp
+++ b/src/security/cert/openssl/X509Certificate_OpenSSL.cpp
@@ -158,17 +158,17 @@ void* X509Certificate_OpenSSL::getInternalData()
// static
-ref <X509Certificate> X509Certificate_OpenSSL::importInternal(X509* cert)
+shared_ptr <X509Certificate> X509Certificate_OpenSSL::importInternal(X509* cert)
{
if (cert)
- return vmime::create <X509Certificate_OpenSSL>(reinterpret_cast <X509 *>(cert));
+ return make_shared <X509Certificate_OpenSSL>(reinterpret_cast <X509 *>(cert));
- return NULL;
+ return null;
}
// static
-ref <X509Certificate> X509Certificate::import(utility::inputStream& is)
+shared_ptr <X509Certificate> X509Certificate::import(utility::inputStream& is)
{
byteArray bytes;
utility::stream::value_type chunk[4096];
@@ -184,17 +184,17 @@ ref <X509Certificate> X509Certificate::import(utility::inputStream& is)
// static
-ref <X509Certificate> X509Certificate::import
+shared_ptr <X509Certificate> X509Certificate::import
(const byte_t* data, const size_t length)
{
- ref <X509Certificate_OpenSSL> cert = vmime::create <X509Certificate_OpenSSL>();
+ shared_ptr <X509Certificate_OpenSSL> cert = make_shared <X509Certificate_OpenSSL>();
BIO* membio = BIO_new_mem_buf(const_cast <byte_t*>(data), length);
if (!PEM_read_bio_X509(membio, &(cert->m_data->cert), 0, 0))
{
BIO_vfree(membio);
- return NULL;
+ return null;
}
BIO_vfree(membio);
@@ -270,10 +270,10 @@ const byteArray X509Certificate_OpenSSL::getSerialNumber() const
}
-bool X509Certificate_OpenSSL::checkIssuer(ref <const X509Certificate> cert_) const
+bool X509Certificate_OpenSSL::checkIssuer(shared_ptr <const X509Certificate> cert_) const
{
- ref <const X509Certificate_OpenSSL> cert =
- cert_.dynamicCast <const X509Certificate_OpenSSL>();
+ shared_ptr <const X509Certificate_OpenSSL> cert =
+ dynamicCast <const X509Certificate_OpenSSL>(cert_);
// Get issuer for this cert
BIO *out;
@@ -297,10 +297,10 @@ bool X509Certificate_OpenSSL::checkIssuer(ref <const X509Certificate> cert_) con
}
-bool X509Certificate_OpenSSL::verify(ref <const X509Certificate> caCert_) const
+bool X509Certificate_OpenSSL::verify(shared_ptr <const X509Certificate> caCert_) const
{
- ref <const X509Certificate_OpenSSL> caCert =
- caCert_.dynamicCast <const X509Certificate_OpenSSL>();
+ shared_ptr <const X509Certificate_OpenSSL> caCert =
+ dynamicCast <const X509Certificate_OpenSSL>(caCert_);
bool verified = false;
@@ -550,10 +550,10 @@ int X509Certificate_OpenSSL::getVersion() const
}
-bool X509Certificate_OpenSSL::equals(ref <const certificate> other) const
+bool X509Certificate_OpenSSL::equals(shared_ptr <const certificate> other) const
{
- ref <const X509Certificate_OpenSSL> otherX509 =
- other.dynamicCast <const X509Certificate_OpenSSL>();
+ shared_ptr <const X509Certificate_OpenSSL> otherX509 =
+ dynamicCast <const X509Certificate_OpenSSL>(other);
if (!otherX509)
return false;