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.

95 lines
3.0 KiB

  1. From fa8f6fcd33e829cbe3ef3e4a92fa34cba3f20c91 Mon Sep 17 00:00:00 2001
  2. From: Rosen Penev <rosenp@gmail.com>
  3. Date: Sun, 20 Sep 2020 20:18:18 -0700
  4. Subject: [PATCH] openssl: fix compilation without deprecated APIs
  5. Added missing headers, removed initialization, and fixed APIs.
  6. Signed-off-by: Rosen Penev <rosenp@gmail.com>
  7. ---
  8. openssl.c | 8 ++------
  9. openssl_certs.c | 9 +++++----
  10. openssl_tls.c | 5 -----
  11. 3 files changed, 7 insertions(+), 15 deletions(-)
  12. diff --git a/openssl.c b/openssl.c
  13. index ba097a5..76c817b 100644
  14. --- a/openssl.c
  15. +++ b/openssl.c
  16. @@ -22,21 +22,17 @@
  17. **/
  18. #include <openssl/ssl.h>
  19. +#include <openssl/bn.h>
  20. +#include <openssl/rsa.h>
  21. #include <openssl/err.h>
  22. #include "openssl.h"
  23. #include "errstack.h"
  24. void openssl_init(void) {
  25. - SSL_load_error_strings();
  26. - OpenSSL_add_ssl_algorithms();
  27. }
  28. void openssl_deinit(void) {
  29. - EVP_cleanup();
  30. - CRYPTO_cleanup_all_ex_data();
  31. - SSL_COMP_free_compression_methods();
  32. - ERR_free_strings();
  33. }
  34. static void errstack_free_X509(struct errstack_element_t *element) {
  35. diff --git a/openssl_certs.c b/openssl_certs.c
  36. index 021b573..a062a24 100644
  37. --- a/openssl_certs.c
  38. +++ b/openssl_certs.c
  39. @@ -27,6 +27,7 @@
  40. #include <openssl/ssl.h>
  41. #include <openssl/err.h>
  42. #include <openssl/bn.h>
  43. +#include <openssl/rsa.h>
  44. #include <openssl/x509v3.h>
  45. #include "ipfwd.h"
  46. @@ -280,8 +281,8 @@ X509* openssl_create_certificate(const struct certificatespec_t *spec) {
  47. BN_free(serial);
  48. /* Set lifetime */
  49. - X509_gmtime_adj(X509_get_notBefore(cert), -spec->validity_predate_seconds);
  50. - X509_gmtime_adj(X509_get_notAfter(cert), spec->validity_seconds);
  51. + X509_gmtime_adj(X509_getm_notBefore(cert), -spec->validity_predate_seconds);
  52. + X509_gmtime_adj(X509_getm_notAfter(cert), spec->validity_seconds);
  53. /* Set public key */
  54. X509_set_pubkey(cert, spec->subject_pubkey);
  55. @@ -357,8 +358,8 @@ X509* openssl_create_certificate(const struct certificatespec_t *spec) {
  56. return cert;
  57. }
  58. -static bool is_certificate_expired(X509 *cert) {
  59. - return X509_cmp_current_time(X509_get_notAfter(cert)) <= 0;
  60. +static bool is_certificate_expired(const X509 *cert) {
  61. + return X509_cmp_current_time(X509_get0_notAfter(cert)) <= 0;
  62. }
  63. X509* openssl_load_stored_certificate(const struct certificatespec_t *certspec, const char *filename, bool recreate_when_expired, bool recreate_when_key_mismatch) {
  64. diff --git a/openssl_tls.c b/openssl_tls.c
  65. index 4ba19a3..96a12ec 100644
  66. --- a/openssl_tls.c
  67. +++ b/openssl_tls.c
  68. @@ -146,11 +146,6 @@ struct tls_connection_t openssl_tls_connect(const struct tls_connection_request_
  69. SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, NULL);
  70. SSL_CTX_set_cert_verify_callback(sslctx, cert_verify_callback, &result);
  71. }
  72. - if (!SSL_CTX_set_ecdh_auto(sslctx, 1)) {
  73. - logmsgext(LLVL_ERROR, FLAG_OPENSSL_ERROR, "openssl_tls %s: SSL_CTX_set_ecdh_auto() failed.", request->is_server ? "server" : "client");
  74. - SSL_CTX_free(sslctx);
  75. - return result;
  76. - }
  77. if (request->config && request->config->cert) {
  78. if (SSL_CTX_use_certificate(sslctx, request->config->cert) != 1) {
  79. --
  80. 2.20.1