diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-11-11 20:55:05 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-11-11 20:55:05 (GMT) |
commit | ca0cd342f5b339b4bc6188faddf58638ce26e4f1 (patch) | |
tree | 7307f37c09cd26a530b205174604ba420f26f0b0 | |
parent | 403cbfef86c0ffab43064f49b578b22280ac8a6e (diff) | |
download | swift-contrib-ca0cd342f5b339b4bc6188faddf58638ce26e4f1.zip swift-contrib-ca0cd342f5b339b4bc6188faddf58638ce26e4f1.tar.bz2 |
Handle null OpenSSL X509 cert pointers better.
-rw-r--r-- | Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp index 77c0aee..8c6cb25 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp @@ -27,6 +27,10 @@ OpenSSLCertificate::OpenSSLCertificate(const ByteArray& der) { } ByteArray OpenSSLCertificate::toDER() const { + if (!cert) { + return ByteArray(); + } + ByteArray result; result.resize(i2d_X509(cert.get(), NULL)); unsigned char* p = reinterpret_cast<unsigned char*>(result.getData()); @@ -35,6 +39,10 @@ ByteArray OpenSSLCertificate::toDER() const { } void OpenSSLCertificate::parse() { + if (!cert) { + return; + } + // Subject name X509_NAME* subjectName = X509_get_subject_name(cert.get()); if (subjectName) { |