You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.9 KiB

  1. --- a/mutt_ssl.c
  2. +++ b/mutt_ssl.c
  3. @@ -28,6 +28,14 @@
  4. #include <openssl/rand.h>
  5. #include <openssl/evp.h>
  6. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  7. +#define X509_get0_notBefore X509_get_notBefore
  8. +#define X509_get0_notAfter X509_get_notAfter
  9. +#define X509_getm_notBefore X509_get_notBefore
  10. +#define X509_getm_notAfter X509_get_notAfter
  11. +#define X509_STORE_CTX_get0_chain X509_STORE_CTX_get_chain
  12. +#endif
  13. +
  14. #undef _
  15. #include <string.h>
  16. @@ -121,8 +129,8 @@ static int ssl_load_certificates (SSL_CTX *ctx)
  17. while (NULL != PEM_read_X509 (fp, &cert, NULL, NULL))
  18. {
  19. - if ((X509_cmp_current_time (X509_get_notBefore (cert)) >= 0) ||
  20. - (X509_cmp_current_time (X509_get_notAfter (cert)) <= 0))
  21. + if ((X509_cmp_current_time (X509_get0_notBefore (cert)) >= 0) ||
  22. + (X509_cmp_current_time (X509_get0_notAfter (cert)) <= 0))
  23. {
  24. dprint (2, (debugfile, "ssl_load_certificates: filtering expired cert: %s\n",
  25. X509_NAME_oneline (X509_get_subject_name (cert), buf, sizeof (buf))));
  26. @@ -331,10 +339,12 @@ static int ssl_init (void)
  27. }
  28. }
  29. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  30. /* I don't think you can do this just before reading the error. The call
  31. * itself might clobber the last SSL error. */
  32. SSL_load_error_strings();
  33. SSL_library_init();
  34. +#endif
  35. init_complete = 1;
  36. return 0;
  37. }
  38. @@ -811,7 +821,7 @@ static int check_certificate_expiration (X509 *peercert, int silent)
  39. {
  40. if (option (OPTSSLVERIFYDATES) != MUTT_NO)
  41. {
  42. - if (X509_cmp_current_time (X509_get_notBefore (peercert)) >= 0)
  43. + if (X509_cmp_current_time (X509_get0_notBefore (peercert)) >= 0)
  44. {
  45. if (!silent)
  46. {
  47. @@ -821,7 +831,7 @@ static int check_certificate_expiration (X509 *peercert, int silent)
  48. }
  49. return 0;
  50. }
  51. - if (X509_cmp_current_time (X509_get_notAfter (peercert)) <= 0)
  52. + if (X509_cmp_current_time (X509_get0_notAfter (peercert)) <= 0)
  53. {
  54. if (!silent)
  55. {
  56. @@ -1069,7 +1079,7 @@ static int ssl_verify_callback (int preverify_ok, X509_STORE_CTX *ctx)
  57. cert = X509_STORE_CTX_get_current_cert (ctx);
  58. pos = X509_STORE_CTX_get_error_depth (ctx);
  59. - len = sk_X509_num (X509_STORE_CTX_get_chain (ctx));
  60. + len = sk_X509_num (X509_STORE_CTX_get0_chain (ctx));
  61. dprint (1, (debugfile,
  62. "ssl_verify_callback: checking cert chain entry %s (preverify: %d skipmode: %d)\n",
  63. @@ -1198,9 +1208,9 @@ static int interactive_check_cert (X509 *cert, int idx, int len, SSL *ssl, int a
  64. row++;
  65. snprintf (menu->dialog[row++], SHORT_STRING, "%s", _("This certificate is valid"));
  66. snprintf (menu->dialog[row++], SHORT_STRING, _(" from %s"),
  67. - asn1time_to_string (X509_get_notBefore (cert)));
  68. + asn1time_to_string (X509_getm_notBefore (cert)));
  69. snprintf (menu->dialog[row++], SHORT_STRING, _(" to %s"),
  70. - asn1time_to_string (X509_get_notAfter (cert)));
  71. + asn1time_to_string (X509_getm_notAfter (cert)));
  72. row++;
  73. buf[0] = '\0';