summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2018-01-05 15:45:34 (GMT)
committerTobias Markmann <tm@ayena.de>2018-01-30 11:46:28 (GMT)
commit9eaa75b907a515a65ccb2002632fbf2f30c5aee8 (patch)
tree94102960e7814eebb5f8646dacf34ad06f8c1f8d /Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp
parent1f70a58280db165c0df80c81b41986f1d67c0a95 (diff)
downloadswift-9eaa75b907a515a65ccb2002632fbf2f30c5aee8.zip
swift-9eaa75b907a515a65ccb2002632fbf2f30c5aee8.tar.bz2
Modernize OpenSSL crypto backend
* use std::unique_ptr for memory management of dynamic OpenSSL objects * use an initializer class and static instance of it to correctly initialize/finalize OpenSSL on first use * use enum class instead of simple enum for state * use nullptr instead of NULL Test-Information: Builds and tests pass on macOS 10.13.2 with clang-trunk and ASAN. Change-Id: I346f14e21c34871c1900a8e1ac000450770a0bbe
Diffstat (limited to 'Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp')
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp
index 17ac8cc..8d2d965 100644
--- a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp
+++ b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp
@@ -30,7 +30,7 @@ OpenSSLCertificate::OpenSSLCertificate(const ByteArray& der) {
#else
const unsigned char* p = vecptr(der);
#endif
- cert = std::shared_ptr<X509>(d2i_X509(NULL, &p, der.size()), X509_free);
+ cert = std::shared_ptr<X509>(d2i_X509(nullptr, &p, der.size()), X509_free);
if (!cert) {
SWIFT_LOG(warning) << "Error creating certificate from DER data" << std::endl;
}
@@ -42,7 +42,7 @@ ByteArray OpenSSLCertificate::toDER() const {
if (!cert) {
return result;
}
- result.resize(i2d_X509(cert.get(), NULL));
+ result.resize(i2d_X509(cert.get(), nullptr));
unsigned char* p = vecptr(result);
i2d_X509(cert.get(), &p);
return result;