Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/6.0] Add dynamic shim for SSL_CTX_set_options and SSL_set_options #67145

Merged
merged 5 commits into from
Apr 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,53 @@ static void EnsureLibSsl10Initialized()
}
#endif

#ifdef FEATURE_DISTRO_AGNOSTIC_SSL
// redirect all SSL_CTX_set_options and SSL_set_options calls via dynamic shims
// to work around ABI breaking change between 1.1 and 3.0

#undef SSL_CTX_set_options
#define SSL_CTX_set_options SSL_CTX_set_options_dynamic
static uint64_t SSL_CTX_set_options_dynamic(SSL_CTX* ctx, uint64_t options)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-function-type"
if (API_EXISTS(ERR_new)) // OpenSSL 3.0 sentinel function
{
// OpenSSL 3.0 and newer, use uint64_t for options
uint64_t (*func)(SSL_CTX* ctx, uint64_t op) = (uint64_t(*)(SSL_CTX*, uint64_t))SSL_CTX_set_options_ptr;
return func(ctx, options);
}
else
{
// OpenSSL 1.1 and earlier, use uint32_t for options
uint32_t (*func)(SSL_CTX* ctx, uint32_t op) = (uint32_t(*)(SSL_CTX*, uint32_t))SSL_CTX_set_options_ptr;
return func(ctx, (uint32_t)options);
}
#pragma clang diagnostic pop
}

#undef SSL_set_options
#define SSL_set_options SSL_set_options_dynamic
static uint64_t SSL_set_options_dynamic(SSL* s, uint64_t options)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-function-type"
if (API_EXISTS(ERR_new)) // OpenSSL 3.0 sentinel function
{
// OpenSSL 3.0 and newer, use uint64_t for options
uint64_t (*func)(SSL* s, uint64_t op) = (uint64_t(*)(SSL*, uint64_t))SSL_set_options_ptr;
return func(s, options);
}
else
{
// OpenSSL 1.1 and earlier, use uint32_t for options
uint32_t (*func)(SSL* s, uint32_t op) = (uint32_t(*)(SSL*, uint32_t))SSL_set_options_ptr;
return func(s, (uint32_t)options);
}
#pragma clang diagnostic pop
}
#endif

static int32_t g_config_specified_ciphersuites = 0;

static void DetectCiphersuiteConfiguration()
Expand Down