]> granicus.if.org Git - mutt/commitdiff
Wrap ssl init calls for LibreSSL too.
authorKevin McCarthy <kevin@8t8.us>
Thu, 10 Jan 2019 17:56:41 +0000 (09:56 -0800)
committerKevin McCarthy <kevin@8t8.us>
Sat, 19 Jan 2019 03:36:44 +0000 (19:36 -0800)
It looks like LibreSSL does not perform automatic initialization of
the library and error strings.

Since LibreSSL defines OPENSSL_VERSION_NUMBER as a "version 2",
add a check if LIBRESSL_VERSION_NUMBER is defined and call the
initialization functions for that case.

mutt_ssl.c

index 8816be417f3edd8f91f55526a22168d4b6e1d673..0479ceec09c72d571c1a7f8e0d4e315d1fb44e4b 100644 (file)
 #include <openssl/rand.h>
 #include <openssl/evp.h>
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
+/* LibreSSL defines OPENSSL_VERSION_NUMBER but sets it to 0x20000000L.
+ * So technically we don't need the defined(OPENSSL_VERSION_NUMBER) check.
+ */
+#if (defined(OPENSSL_VERSION_NUMBER)  && OPENSSL_VERSION_NUMBER  < 0x10100000L) || \
+    (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
 #define X509_get0_notBefore X509_get_notBefore
 #define X509_get0_notAfter X509_get_notAfter
 #define X509_getm_notBefore X509_get_notBefore
@@ -339,7 +343,10 @@ static int ssl_init (void)
     }
   }
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+/* OpenSSL performs automatic initialization as of 1.1.
+ * However LibreSSL does not (as of 2.8.3). */
+#if (defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L) || \
+    (defined(LIBRESSL_VERSION_NUMBER))
   /* I don't think you can do this just before reading the error. The call
    * itself might clobber the last SSL error. */
   SSL_load_error_strings();