From 7e8dab02ce8a8acf750153c46c19215223dcc67c Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Fri, 9 Mar 2012 15:25:48 -0800 Subject: Add a version check, since older versions of OpenSSL are missing ameth --- OpenSSL/crypto/crl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/OpenSSL/crypto/crl.c b/OpenSSL/crypto/crl.c index 543708e..3f56d83 100644 --- a/OpenSSL/crypto/crl.c +++ b/OpenSSL/crypto/crl.c @@ -2,7 +2,6 @@ #define crypto_MODULE #include "crypto.h" - static X509_REVOKED * X509_REVOKED_dup(X509_REVOKED *orig) { X509_REVOKED *dupe = NULL; @@ -138,15 +137,19 @@ crypto_CRL_export(crypto_CRLObj *self, PyObject *args, PyObject *keywds) { return NULL; } - /* Some versions of OpenSSL check for this, but more recent versions seem - * not to. + +#if OPENSSL_VERSION_NUMBER >= 0x01000000L + /* Older versions of OpenSSL had no problem with trying to export using an + * uninitialized key. Newer versions segfault, instead. We can only check + * on the new versions, though, because the old versions don't even have the + * field that the segfault is triggered by. */ if (!key->pkey->ameth) { PyErr_SetString( crypto_Error, "Cannot export with an unitialized key"); return NULL; } - +#endif bio = BIO_new(BIO_s_mem()); tmptm = ASN1_TIME_new(); -- cgit v1.2.1