diff options
author | Vincent Richard <[email protected]> | 2006-12-08 13:07:06 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2006-12-08 13:07:06 +0000 |
commit | f95b91c547c1ba7491f493693dafcd7c2b7c6251 (patch) | |
tree | eeee17142f2d07387ca55c86a8cd936ca7c839e3 | |
parent | Allow a line containing only spaces as header separator. (diff) | |
download | vmime-f95b91c547c1ba7491f493693dafcd7c2b7c6251.tar.gz vmime-f95b91c547c1ba7491f493693dafcd7c2b7c6251.zip |
Fixed invalid reuse of cert with gnutls_x509_crt_import (thanks to Benjamin Biron).
-rw-r--r-- | src/security/cert/X509Certificate.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/security/cert/X509Certificate.cpp b/src/security/cert/X509Certificate.cpp index 65de1093..03af4efe 100644 --- a/src/security/cert/X509Certificate.cpp +++ b/src/security/cert/X509Certificate.cpp @@ -94,19 +94,21 @@ ref <X509Certificate> X509Certificate::import(utility::inputStream& is) ref <X509Certificate> X509Certificate::import (const byte_t* data, const unsigned int length) { - ref <X509Certificate> cert = vmime::create <X509Certificate>(); - gnutls_datum buffer; buffer.data = const_cast <byte_t*>(data); buffer.size = length; // Try DER format - if (gnutls_x509_crt_import(cert->m_data->cert, &buffer, GNUTLS_X509_FMT_DER) >= 0) - return cert; + ref <X509Certificate> derCert = vmime::create <X509Certificate>(); + + if (gnutls_x509_crt_import(derCert->m_data->cert, &buffer, GNUTLS_X509_FMT_DER) >= 0) + return derCert; // Try PEM format - if (gnutls_x509_crt_import(cert->m_data->cert, &buffer, GNUTLS_X509_FMT_PEM) >= 0) - return cert; + ref <X509Certificate> pemCert = vmime::create <X509Certificate>(); + + if (gnutls_x509_crt_import(pemCert->m_data->cert, &buffer, GNUTLS_X509_FMT_PEM) >= 0) + return pemCert; return NULL; } |