Skip to content

Commit

Permalink
Make the OpenSSL 1.1 compatibility code conditional with a VibeUseOpe…
Browse files Browse the repository at this point in the history
…nSSL11 version constant.

Fixes #1758.

Closes #1759. Closes #1748. Closes #1651.
  • Loading branch information
s-ludwig committed Aug 12, 2017
1 parent ba9268c commit 44ee1ad
Showing 1 changed file with 51 additions and 52 deletions.
103 changes: 51 additions & 52 deletions tls/vibe/stream/openssl.d
Original file line number Diff line number Diff line change
Expand Up @@ -46,76 +46,75 @@ version(VibeForceALPN) enum alpn_forced = true;
else enum alpn_forced = false;
enum haveALPN = OPENSSL_VERSION_NUMBER >= 0x10200000 || alpn_forced;

// openssl 1.1.0 hack
version (Have_openssl) {
extern(C) const(SSL_METHOD)* TLS_client_method();
// openssl 1.1.0 hack: provides a 1.0.x API in terms of the 1.1.x API
version (VibeUseOpenSSL11) {
extern(C) const(SSL_METHOD)* TLS_client_method();

const(SSL_METHOD)* SSLv23_client_method() {
return TLS_client_method();
}

extern(C) const(SSL_METHOD)* TLS_server_method();
const(SSL_METHOD)* SSLv23_client_method() {
return TLS_client_method();
}

const(SSL_METHOD)* SSLv23_server_method() {
return TLS_server_method();
}
extern(C) const(SSL_METHOD)* TLS_server_method();

// this does nothing in > openssl 1.1.0
void SSL_load_error_strings() {}
const(SSL_METHOD)* SSLv23_server_method() {
return TLS_server_method();
}

extern(C) int OPENSSL_init_ssl(ulong opts, const void* settings);
// this does nothing in > openssl 1.1.0
void SSL_load_error_strings() {}

// # define SSL_library_init() OPENSSL_init_ssl(0, NULL)
int SSL_library_init() {
return OPENSSL_init_ssl(0, null);
}
extern(C) int OPENSSL_init_ssl(ulong opts, const void* settings);

//# define CRYPTO_num_locks() (1)
int CRYPTO_num_locks() {
return 1;
}
// # define SSL_library_init() OPENSSL_init_ssl(0, NULL)
int SSL_library_init() {
return OPENSSL_init_ssl(0, null);
}

void CRYPTO_set_id_callback(T)(T t) {
}
//# define CRYPTO_num_locks() (1)
int CRYPTO_num_locks() {
return 1;
}

void CRYPTO_set_locking_callback(T)(T t) {
void CRYPTO_set_id_callback(T)(T t) {
}

}
void CRYPTO_set_locking_callback(T)(T t) {

// #define SSL_get_ex_new_index(l, p, newf, dupf, freef) \
// CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef)
}

extern(C) int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
CRYPTO_EX_free *free_func);
// #define SSL_get_ex_new_index(l, p, newf, dupf, freef) \
// CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef)

int SSL_get_ex_new_index(long argl, void *argp,
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
CRYPTO_EX_free *free_func) {
// # define CRYPTO_EX_INDEX_SSL 0
return CRYPTO_get_ex_new_index(0, argl, argp, new_func, dup_func,
free_func);
}
extern(C) int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
CRYPTO_EX_free *free_func);

extern(C) BIGNUM* BN_get_rfc3526_prime_2048(BIGNUM *bn);
int SSL_get_ex_new_index(long argl, void *argp,
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
CRYPTO_EX_free *free_func) {
// # define CRYPTO_EX_INDEX_SSL 0
return CRYPTO_get_ex_new_index(0, argl, argp, new_func, dup_func,
free_func);
}

BIGNUM* get_rfc3526_prime_2048(BIGNUM *bn) {
return BN_get_rfc3526_prime_2048(bn);
}
extern(C) BIGNUM* BN_get_rfc3526_prime_2048(BIGNUM *bn);

// # define sk_num OPENSSL_sk_num
extern(C) int OPENSSL_sk_num(const void *);
extern(C) int sk_num(const void *a) {
return OPENSSL_sk_num(a);
}
BIGNUM* get_rfc3526_prime_2048(BIGNUM *bn) {
return BN_get_rfc3526_prime_2048(bn);
}

// # define sk_value OPENSSL_sk_value
extern(C) void *OPENSSL_sk_value(const void *, int);
// # define sk_num OPENSSL_sk_num
extern(C) int OPENSSL_sk_num(const void *);
extern(C) int sk_num(const void *a) {

This comment has been minimized.

Copy link
@John-Colvin

John-Colvin Aug 15, 2017

Contributor

why is this extern(C). It means it clashes with the declaration in https://github.com/D-Programming-Deimos/openssl/blob/master/deimos/openssl/stack.d#L79

The same applies for sk_value

This comment has been minimized.

Copy link
@John-Colvin

John-Colvin Aug 15, 2017

Contributor

This comment has been minimized.

Copy link
@s-ludwig

s-ludwig Aug 15, 2017

Author Member

@burner, these two in particular don't appear to be used anywhere, was this part of some linker trickery, or just something left over?

This comment has been minimized.

Copy link
@burner

burner Aug 15, 2017

Contributor

they are left overs, as far as I remember

return OPENSSL_sk_num(a);
}

extern(C) void *sk_value(const void *s, int l) {
return OPENSSL_sk_value(s, l);
}
// # define sk_value OPENSSL_sk_value
extern(C) void *OPENSSL_sk_value(const void *, int);

extern(C) void *sk_value(const void *s, int l) {
return OPENSSL_sk_value(s, l);
}
}

/**
Expand Down

0 comments on commit 44ee1ad

Please sign in to comment.