Merge branch 'openssl-1.1-init-fixes-v2'

* openssl-1.1-init-fixes-v2:
  sample/le-proxy: use TLS_method instead of SSLv23_method (latest deprecated)
  test: fix building under openssl 1.1 (init functions has been deprecated)
  le-proxy: fix building under openssl 1.1 (init functions has been deprecated)

Reported-by: varun.net@gmail.com
ML: http://archives.seul.org/libevent/users/Nov-2016/msg00002.html
This commit is contained in:
Azat Khuzhin 2016-12-07 01:14:24 +03:00
commit 18a161f0e7
3 changed files with 9 additions and 2 deletions

View File

@ -3,7 +3,7 @@
#if OPENSSL_VERSION_NUMBER < 0x10100000L #if OPENSSL_VERSION_NUMBER < 0x10100000L
static BIO_METHOD *BIO_meth_new(int type, const char *name) static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
{ {
BIO_METHOD *biom = calloc(1, sizeof(BIO_METHOD)); BIO_METHOD *biom = calloc(1, sizeof(BIO_METHOD));
@ -28,6 +28,8 @@ static BIO_METHOD *BIO_meth_new(int type, const char *name)
#define BIO_get_data(b) (b)->ptr #define BIO_get_data(b) (b)->ptr
#define BIO_get_shutdown(b) (b)->shutdown #define BIO_get_shutdown(b) (b)->shutdown
#define TLS_method SSLv23_method
#endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */ #endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
#endif /* OPENSSL_COMPAT_H */ #endif /* OPENSSL_COMPAT_H */

View File

@ -33,6 +33,7 @@
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include "openssl-compat.h"
static struct event_base *base; static struct event_base *base;
static struct sockaddr_storage listen_on_addr; static struct sockaddr_storage listen_on_addr;
@ -258,16 +259,18 @@ main(int argc, char **argv)
if (use_ssl) { if (use_ssl) {
int r; int r;
#if OPENSSL_VERSION_NUMBER < 0x10100000L
SSL_library_init(); SSL_library_init();
ERR_load_crypto_strings(); ERR_load_crypto_strings();
SSL_load_error_strings(); SSL_load_error_strings();
OpenSSL_add_all_algorithms(); OpenSSL_add_all_algorithms();
#endif
r = RAND_poll(); r = RAND_poll();
if (r == 0) { if (r == 0) {
fprintf(stderr, "RAND_poll() failed.\n"); fprintf(stderr, "RAND_poll() failed.\n");
return 1; return 1;
} }
ssl_ctx = SSL_CTX_new(SSLv23_method()); ssl_ctx = SSL_CTX_new(TLS_method());
} }
listener = evconnlistener_new_bind(base, accept_cb, NULL, listener = evconnlistener_new_bind(base, accept_cb, NULL,

View File

@ -186,6 +186,7 @@ get_ssl_ctx(void)
void void
init_ssl(void) init_ssl(void)
{ {
#if OPENSSL_VERSION_NUMBER < 0x10100000L
SSL_library_init(); SSL_library_init();
ERR_load_crypto_strings(); ERR_load_crypto_strings();
SSL_load_error_strings(); SSL_load_error_strings();
@ -193,6 +194,7 @@ init_ssl(void)
if (SSLeay() != OPENSSL_VERSION_NUMBER) { if (SSLeay() != OPENSSL_VERSION_NUMBER) {
TT_DECLARE("WARN", ("Version mismatch for openssl: compiled with %lx but running with %lx", (unsigned long)OPENSSL_VERSION_NUMBER, (unsigned long) SSLeay())); TT_DECLARE("WARN", ("Version mismatch for openssl: compiled with %lx but running with %lx", (unsigned long)OPENSSL_VERSION_NUMBER, (unsigned long) SSLeay()));
} }
#endif
} }
/* ==================== /* ====================