Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Commit

Permalink
Fix compilation without deprecated OpenSSL 1.1 APIs
Browse files Browse the repository at this point in the history
All threading APIs are gone with 1.1.

dh.h header does not get included with ssl.h automatically when deprecated
APIs are disabled.

X509_getBefore/After were replaced with get0 and getm variants. Switched
to the former as it can be const.
  • Loading branch information
neheb committed Jan 23, 2019
1 parent bdefac6 commit 78e8e41
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
5 changes: 5 additions & 0 deletions evhtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2827,6 +2827,7 @@ htp__accept_cb_(struct evconnlistener * serv, int fd, struct sockaddr * s, int s

#ifndef EVHTP_DISABLE_SSL
#ifndef EVHTP_DISABLE_EVTHR
#if OPENSSL_VERSION_NUMBER < 0x10100000L
static
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
void
Expand Down Expand Up @@ -2854,6 +2855,8 @@ htp__ssl_get_thread_id_(
#else
return tid;
#endif

#endif
}

static void
Expand Down Expand Up @@ -4692,6 +4695,7 @@ evhtp_set_post_accept_cb(evhtp_t * htp, evhtp_post_accept_cb cb, void * arg)

#ifndef EVHTP_DISABLE_SSL
#ifndef EVHTP_DISABLE_EVTHR
#if OPENSSL_VERSION_NUMBER < 0x10100000L
int
evhtp_ssl_use_threads(void)
{
Expand Down Expand Up @@ -4724,6 +4728,7 @@ evhtp_ssl_use_threads(void)
return 0;
}

#endif
#endif

int
Expand Down
1 change: 1 addition & 0 deletions include/evhtp/evhtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#ifndef EVHTP_DISABLE_SSL
#include <event2/bufferevent_ssl.h>
#include <openssl/dh.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/rand.h>
Expand Down
29 changes: 17 additions & 12 deletions sslutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#include "evhtp/sslutils.h"
#include "internal.h"

#if OPENSSL_VERSION_NUMBER < 0x10100000L
#define X509_get0_notBefore X509_get_notBefore
#define X509_get0_notAfter X509_get_notAfter
#endif

unsigned char *
htp_sslutil_subject_tostr(evhtp_ssl_t * ssl) {
unsigned char * subj_str;
Expand Down Expand Up @@ -78,11 +83,11 @@ htp_sslutil_issuer_tostr(evhtp_ssl_t * ssl) {

unsigned char *
htp_sslutil_notbefore_tostr(evhtp_ssl_t * ssl) {
BIO * bio;
X509 * cert;
ASN1_TIME * time;
size_t len;
unsigned char * time_str;
BIO * bio;
X509 * cert;
const ASN1_TIME * time;
size_t len;
unsigned char * time_str;

if (!ssl) {
return NULL;
Expand All @@ -92,7 +97,7 @@ htp_sslutil_notbefore_tostr(evhtp_ssl_t * ssl) {
return NULL;
}

if (!(time = X509_get_notBefore(cert))) {
if (!(time = X509_get0_notBefore(cert))) {
X509_free(cert);
return NULL;
}
Expand Down Expand Up @@ -128,11 +133,11 @@ htp_sslutil_notbefore_tostr(evhtp_ssl_t * ssl) {

unsigned char *
htp_sslutil_notafter_tostr(evhtp_ssl_t * ssl) {
BIO * bio;
X509 * cert;
ASN1_TIME * time;
size_t len;
unsigned char * time_str;
BIO * bio;
X509 * cert;
const ASN1_TIME * time;
size_t len;
unsigned char * time_str;

if (!ssl) {
return NULL;
Expand All @@ -142,7 +147,7 @@ htp_sslutil_notafter_tostr(evhtp_ssl_t * ssl) {
return NULL;
}

if (!(time = X509_get_notAfter(cert))) {
if (!(time = X509_get0_notAfter(cert))) {
X509_free(cert);
return NULL;
}
Expand Down

0 comments on commit 78e8e41

Please sign in to comment.