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

BoringSSL support #814

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,14 @@ endif()
option(ENABLE_SSL_SUPPORT "Enable SSL support" ON)

if (ENABLE_SSL_SUPPORT)
# Manually check OpenSSL version because BoringSSL doesn't support version checking via find_package
set(RMQ_OPENSSL_MIN_VERSION 1.1.1)
find_package(OpenSSL "${RMQ_OPENSSL_MIN_VERSION}" REQUIRED)
find_package(OpenSSL REQUIRED)
if(OPENSSL_VERSION) # Will be empty for BoringSSL
if(OPENSSL_VERSION VERSION_LESS RMQ_OPENSSL_MIN_VERSION)
MESSAGE(FATAL_ERROR "Found OpenSSL version ${OPENSSL_VERSION} but ${RMQ_OPENSSL_MIN_VERSION} or later is required")
endif()
endif()

cmake_push_check_state()
set(THREADS_PREFER_PTHREAD_FLAG ON)
Expand Down
7 changes: 6 additions & 1 deletion cmake/rabbitmq-c-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(RMQ_USES_OPENSSL @ENABLE_SSL_SUPPORT@)
include(CMakeFindDependencyMacro)

if (RMQ_USES_OPENSSL)
find_dependency(OpenSSL @RMQ_OPENSSL_MIN_VERSION@ REQUIRED)
find_dependency(OpenSSL REQUIRED)
if(OPENSSL_VERSION)
if(OPENSSL_VERSION VERSION_LESS RMQ_OPENSSL_MIN_VERSION)
MESSAGE(FATAL_ERROR "Found OpenSSL version @OPENSSL_VERSION@ but @RMQ_OPENSSL_MIN_VERSION@ or later is required")
endif()
endif()
endif ()

include(${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake)
Expand Down
11 changes: 10 additions & 1 deletion librabbitmq/amqp_openssl_bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,15 @@ int amqp_openssl_bio_init(void) {
if (!(amqp_bio_method = BIO_meth_new(BIO_TYPE_SOCKET, "amqp_bio_method"))) {
return AMQP_STATUS_NO_MEMORY;
}

#ifdef OPENSSL_IS_BORINGSSL
BIO_meth_set_create(amqp_bio_method, BIO_s_socket()->create);
BIO_meth_set_destroy(amqp_bio_method, BIO_s_socket()->destroy);
BIO_meth_set_ctrl(amqp_bio_method, BIO_s_socket()->ctrl);
BIO_meth_set_read(amqp_bio_method, BIO_s_socket()->bread);
BIO_meth_set_write(amqp_bio_method, BIO_s_socket()->bwrite);
BIO_meth_set_gets(amqp_bio_method, BIO_s_socket()->bgets);
BIO_meth_set_puts(amqp_bio_method, BIO_s_socket()->bputs);
#else
BIO_meth_set_create(amqp_bio_method, BIO_meth_get_create(BIO_s_socket()));
BIO_meth_set_destroy(amqp_bio_method, BIO_meth_get_destroy(BIO_s_socket()));
BIO_meth_set_ctrl(amqp_bio_method, BIO_meth_get_ctrl(BIO_s_socket()));
Expand All @@ -118,6 +126,7 @@ int amqp_openssl_bio_init(void) {
BIO_meth_set_write(amqp_bio_method, BIO_meth_get_write(BIO_s_socket()));
BIO_meth_set_gets(amqp_bio_method, BIO_meth_get_gets(BIO_s_socket()));
BIO_meth_set_puts(amqp_bio_method, BIO_meth_get_puts(BIO_s_socket()));
#endif

BIO_meth_set_write(amqp_bio_method, amqp_openssl_bio_write);
BIO_meth_set_read(amqp_bio_method, amqp_openssl_bio_read);
Expand Down
Loading