Skip to content

Commit

Permalink
require openssl 1.1.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
wg committed Feb 5, 2017
1 parent 50305ed commit 45e4625
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
master

* Require OpenSSL 1.1.0+

wrk 4.0.2

* Send hostname using TLS SNI.
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ $(ODIR)/%.o : %.c
LUAJIT := $(notdir $(patsubst %.tar.gz,%,$(wildcard deps/LuaJIT*.tar.gz)))
OPENSSL := $(notdir $(patsubst %.tar.gz,%,$(wildcard deps/openssl*.tar.gz)))

OPENSSL_OPTS = no-shared no-ssl2 no-psk no-srp no-dtls no-idea --prefix=$(abspath $(ODIR))
OPENSSL_OPTS = no-shared no-psk no-srp no-dtls no-idea --prefix=$(abspath $(ODIR))

$(ODIR)/$(LUAJIT): deps/$(LUAJIT).tar.gz | $(ODIR)
@tar -C $(ODIR) -xf $<
Expand All @@ -93,7 +93,10 @@ ifeq ($(TARGET), darwin)
else
@$(SHELL) -c "cd $< && ./config $(OPENSSL_OPTS)"
endif
@$(MAKE) -C $< depend install
@$(MAKE) -C $< depend
@$(MAKE) -C $<
@$(MAKE) -C $< install_sw
@touch $@

# ------------

Expand Down
Binary file removed deps/openssl-1.0.2g.tar.gz
Binary file not shown.
Binary file added deps/openssl-1.1.0d.tar.gz
Binary file not shown.
34 changes: 5 additions & 29 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,18 @@

#include "ssl.h"

static pthread_mutex_t *locks;

static void ssl_lock(int mode, int n, const char *file, int line) {
pthread_mutex_t *lock = &locks[n];
if (mode & CRYPTO_LOCK) {
pthread_mutex_lock(lock);
} else {
pthread_mutex_unlock(lock);
}
}

static unsigned long ssl_id() {
return (unsigned long) pthread_self();
}

SSL_CTX *ssl_init() {
SSL_CTX *ctx = NULL;

SSL_load_error_strings();
SSL_library_init();
OpenSSL_add_all_algorithms();

if ((locks = calloc(CRYPTO_num_locks(), sizeof(pthread_mutex_t)))) {
for (int i = 0; i < CRYPTO_num_locks(); i++) {
pthread_mutex_init(&locks[i], NULL);
}

CRYPTO_set_locking_callback(ssl_lock);
CRYPTO_set_id_callback(ssl_id);

if ((ctx = SSL_CTX_new(SSLv23_client_method()))) {
SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
SSL_CTX_set_verify_depth(ctx, 0);
SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_CLIENT);
}
if ((ctx = SSL_CTX_new(SSLv23_client_method()))) {
SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
SSL_CTX_set_verify_depth(ctx, 0);
SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_CLIENT);
}

return ctx;
Expand Down

0 comments on commit 45e4625

Please sign in to comment.