diff --git a/CMakeLists.txt b/CMakeLists.txt index 93b20ebd..66c23e26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/rabbitmq-c-config.cmake.in b/cmake/rabbitmq-c-config.cmake.in index 2b37a677..6f774eff 100644 --- a/cmake/rabbitmq-c-config.cmake.in +++ b/cmake/rabbitmq-c-config.cmake.in @@ -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) diff --git a/librabbitmq/amqp_openssl_bio.c b/librabbitmq/amqp_openssl_bio.c index 5955c75c..28461974 100644 --- a/librabbitmq/amqp_openssl_bio.c +++ b/librabbitmq/amqp_openssl_bio.c @@ -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())); @@ -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);