aboutsummaryrefslogtreecommitdiffstats
path: root/src/security/cert/X509Certificate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/security/cert/X509Certificate.cpp')
-rw-r--r--src/security/cert/X509Certificate.cpp24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/security/cert/X509Certificate.cpp b/src/security/cert/X509Certificate.cpp
index da1322f2..ff58541c 100644
--- a/src/security/cert/X509Certificate.cpp
+++ b/src/security/cert/X509Certificate.cpp
@@ -128,19 +128,11 @@ void X509Certificate::write
gnutls_x509_crt_export(m_data->cert, fmt, NULL, &dataSize);
- byte_t* data = new byte_t[dataSize];
+ std::vector <byte_t> data(dataSize);
- gnutls_x509_crt_export(m_data->cert, fmt, data, &dataSize);
+ gnutls_x509_crt_export(m_data->cert, fmt, &data[0], &dataSize);
- try
- {
- os.write(reinterpret_cast <utility::stream::value_type*>(data), dataSize);
- }
- catch (...)
- {
- delete [] data;
- throw;
- }
+ os.write(reinterpret_cast <utility::stream::value_type*>(&data[0]), dataSize);
}
@@ -212,21 +204,17 @@ const byteArray X509Certificate::getFingerprint(const DigestAlgorithm algo) cons
gnutls_x509_crt_get_fingerprint
(m_data->cert, galgo, NULL, &bufferSize);
- byte_t* buffer = new byte_t[bufferSize];
+ std::vector <byte_t> buffer(bufferSize);
if (gnutls_x509_crt_get_fingerprint
- (m_data->cert, galgo, buffer, &bufferSize) == 0)
+ (m_data->cert, galgo, &buffer[0], &bufferSize) == 0)
{
byteArray res;
- res.insert(res.end(), buffer, buffer + bufferSize);
-
- delete [] buffer;
+ res.insert(res.end(), &buffer[0], &buffer[0] + bufferSize);
return res;
}
- delete [] buffer;
-
return byteArray();
}