summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--20018_all_percona-server-8.0.18-fix-libressl-support.patch310
1 files changed, 310 insertions, 0 deletions
diff --git a/20018_all_percona-server-8.0.18-fix-libressl-support.patch b/20018_all_percona-server-8.0.18-fix-libressl-support.patch
new file mode 100644
index 0000000..3006c23
--- /dev/null
+++ b/20018_all_percona-server-8.0.18-fix-libressl-support.patch
@@ -0,0 +1,310 @@
+--- a/cmake/ssl.cmake
++++ b/cmake/ssl.cmake
+@@ -214,7 +214,8 @@ MACRO (MYSQL_CHECK_SSL)
+ OPENSSL_FIX_VERSION "${OPENSSL_VERSION_NUMBER}"
+ )
+ ENDIF()
+- IF("${OPENSSL_MAJOR_VERSION}.${OPENSSL_MINOR_VERSION}.${OPENSSL_FIX_VERSION}" VERSION_GREATER "1.1.0")
++ CHECK_SYMBOL_EXISTS(TLS1_3_VERSION "openssl/tls1.h" HAVE_TLS1_3_VERSION)
++ IF(HAVE_TLS1_3_VERSION)
+ ADD_DEFINITIONS(-DHAVE_TLSv13)
+ ENDIF()
+ IF(OPENSSL_INCLUDE_DIR AND
+--- a/mysys/my_crypt.cc
++++ b/mysys/my_crypt.cc
+@@ -27,7 +27,7 @@
+
+ #include "my_dbug.h"
+
+-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
++#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
+ #define ERR_remove_state(X) ERR_clear_error()
+ #else
+ #define EVP_CIPHER_CTX_buf_noconst(ctx) ((ctx)->buf)
+@@ -86,7 +86,7 @@ class MyEncryptionCTX : private boost::noncopyable {
+ };
+
+ MyEncryptionCTX::MyEncryptionCTX() {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ ctx = new EVP_CIPHER_CTX();
+ EVP_CIPHER_CTX_init(ctx);
+ #else
+@@ -95,7 +95,8 @@ MyEncryptionCTX::MyEncryptionCTX() {
+ }
+
+ MyEncryptionCTX::~MyEncryptionCTX() {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
++ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02090000fL)
+ EVP_CIPHER_CTX_cleanup(ctx);
+ delete ctx;
+ #else
+--- a/mysys/my_md5.cc
++++ b/mysys/my_md5.cc
+@@ -56,7 +56,9 @@ static void my_md5_hash(unsigned char *digest, unsigned const char *buf,
+ int compute_md5_hash(char *digest, const char *buf, int len) {
+ int retval = 0;
+ int fips_mode = 0;
++#ifndef LIBRESSL_VERSION_NUMBER
+ fips_mode = FIPS_mode();
++#endif
+ /* If fips mode is ON/STRICT restricted method calls will result into abort,
+ * skipping call. */
+ if (fips_mode == 0) {
+--- a/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/xcom_ssl_transport.c
++++ b/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/xcom_ssl_transport.c
+@@ -329,6 +329,7 @@ error:
+ return 1;
+ }
+
++#ifndef LIBRESSL_VERSION_NUMBER
+ #define OPENSSL_ERROR_LENGTH 512
+ static int configure_ssl_fips_mode(const uint fips_mode) {
+ int rc = -1;
+@@ -352,6 +353,7 @@ static int configure_ssl_fips_mode(const uint fips_mode) {
+ EXIT:
+ return rc;
+ }
++#endif
+
+ static int configure_ssl_ca(SSL_CTX *ssl_ctx, const char *ca_file,
+ const char *ca_path) {
+@@ -555,10 +557,12 @@ int xcom_init_ssl(const char *server_key_file, const char *server_cert_file,
+ int verify_server = SSL_VERIFY_NONE;
+ int verify_client = SSL_VERIFY_NONE;
+
++#ifndef LIBRESSL_VERSION_NUMBER
+ if (configure_ssl_fips_mode(ssl_fips_mode) != 1) {
+ G_ERROR("Error setting the ssl fips mode");
+ goto error;
+ }
++#endif
+
+ SSL_library_init();
+ SSL_load_error_strings();
+@@ -622,7 +626,7 @@ error:
+ void xcom_cleanup_ssl() {
+ if (!xcom_use_ssl()) return;
+
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ ERR_remove_thread_state(0);
+ #endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
+ }
+--- a/plugin/x/client/xconnection_impl.cc
++++ b/plugin/x/client/xconnection_impl.cc
+@@ -521,6 +521,7 @@ XError Connection_impl::get_ssl_error(const int error_id) {
+ return XError(CR_SSL_CONNECTION_ERROR, buffer);
+ }
+
++#ifndef LIBRESSL_VERSION_NUMBER
+ /**
+ Set fips mode in openssl library,
+ When we set fips mode ON/STRICT, it will perform following operations:
+@@ -559,6 +560,7 @@ int set_fips_mode(const uint fips_mode, char err_string[OPENSSL_ERROR_LENGTH]) {
+ EXIT:
+ return rc;
+ }
++#endif
+
+ XError Connection_impl::activate_tls() {
+ if (nullptr == m_vio) return get_socket_error(SOCKET_ECONNRESET);
+@@ -569,11 +571,13 @@ XError Connection_impl::activate_tls() {
+ if (!m_context->m_ssl_config.is_configured())
+ return XError{CR_SSL_CONNECTION_ERROR, ER_TEXT_TLS_NOT_CONFIGURATED, true};
+
++#ifndef LIBRESSL_VERSION_NUMBER
+ char err_string[OPENSSL_ERROR_LENGTH] = {'\0'};
+ if (set_fips_mode(static_cast<int>(m_context->m_ssl_config.m_ssl_fips_mode),
+ err_string) != 1) {
+ return XError{CR_SSL_CONNECTION_ERROR, err_string, true};
+ }
++#endif
+ auto ssl_ctx_flags = process_tls_version(
+ details::null_when_empty(m_context->m_ssl_config.m_tls_version));
+
+--- a/router/src/http/src/tls_client_context.cc
++++ b/router/src/http/src/tls_client_context.cc
+@@ -54,7 +54,7 @@ void TlsClientContext::verify(TlsVerify verify) {
+
+ void TlsClientContext::cipher_suites(const std::string &ciphers) {
+ // TLSv1.3 ciphers are controlled via SSL_CTX_set_ciphersuites()
+-#if OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 1)
++#ifdef TLS1_3_VERSION
+ if (1 != SSL_CTX_set_ciphersuites(ssl_ctx_.get(), ciphers.c_str())) {
+ throw TlsError("set-cipher-suites");
+ }
+--- a/router/src/http/src/tls_context.cc
++++ b/router/src/http/src/tls_context.cc
+@@ -91,7 +91,7 @@ static int o11x_version(TlsVersion version) {
+ return TLS1_1_VERSION;
+ case TlsVersion::TLS_1_2:
+ return TLS1_2_VERSION;
+-#if OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 1)
++#ifdef TLS1_3_VERSION
+ case TlsVersion::TLS_1_3:
+ return TLS1_3_VERSION;
+ #endif
+@@ -120,9 +120,11 @@ void TlsContext::version_range(TlsVersion min_version, TlsVersion max_version) {
+ switch (min_version) {
+ default:
+ // unknown, leave all disabled
++#ifdef TLS1_3_VERSION
+ // fallthrough
+ case TlsVersion::TLS_1_3:
+ opts |= SSL_OP_NO_TLSv1_2;
++#endif
+ // fallthrough
+ case TlsVersion::TLS_1_2:
+ opts |= SSL_OP_NO_TLSv1_1;
+@@ -170,8 +172,10 @@ TlsVersion TlsContext::min_version() const {
+ return TlsVersion::TLS_1_1;
+ case TLS1_2_VERSION:
+ return TlsVersion::TLS_1_2;
++#ifdef TLS1_3_VERSION
+ case TLS1_3_VERSION:
+ return TlsVersion::TLS_1_3;
++#endif
+ case 0:
+ return TlsVersion::AUTO;
+ default:
+@@ -230,7 +234,8 @@ TlsContext::InfoCallback TlsContext::info_callback() const {
+ }
+
+ int TlsContext::security_level() const {
+-#if OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 0)
++#if OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 0) && \
++ !defined(LIBRESSL_VERSION_NUMBER)
+ return SSL_CTX_get_security_level(ssl_ctx_.get());
+ #else
+ return 0;
+--- a/router/src/http/src/tls_server_context.cc
++++ b/router/src/http/src/tls_server_context.cc
+@@ -166,7 +166,8 @@ void TlsServerContext::init_tmp_dh(const std::string &dh_params) {
+ }
+
+ } else {
+-#if OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 0)
++#if OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 0) && \
++ !defined(LIBRESSL_VERSION_NUMBER)
+ dh2048.reset(DH_get_2048_256());
+ #else
+ /*
+--- a/sql-common/client.cc
++++ b/sql-common/client.cc
+@@ -7881,7 +7881,7 @@ int STDCALL mysql_options(MYSQL *mysql, enum mysql_option option,
+ #endif
+ break;
+ case MYSQL_OPT_SSL_FIPS_MODE: {
+-#if defined(HAVE_OPENSSL)
++#if defined(HAVE_OPENSSL) && !defined(LIBRESSL_VERSION_NUMBER)
+ char ssl_err_string[OPENSSL_ERROR_LENGTH] = {'\0'};
+ ENSURE_EXTENSIONS_PRESENT(&mysql->options);
+ mysql->options.extension->ssl_fips_mode = *static_cast<const uint *>(arg);
+--- a/sql/mysqld.cc
++++ b/sql/mysqld.cc
+@@ -5047,7 +5047,7 @@ static int init_thread_environment() {
+
+ static PSI_memory_key key_memory_openssl = PSI_NOT_INSTRUMENTED;
+
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ #define FILE_LINE_ARGS
+ #else
+ #define FILE_LINE_ARGS , const char *, int
+@@ -5083,12 +5083,14 @@ static void init_ssl() {
+ }
+
+ static int init_ssl_communication() {
++#ifndef LIBRESSL_VERSION_NUMBER
+ char ssl_err_string[OPENSSL_ERROR_LENGTH] = {'\0'};
+ int ret_fips_mode = set_fips_mode(opt_ssl_fips_mode, ssl_err_string);
+ if (ret_fips_mode != 1) {
+ LogErr(ERROR_LEVEL, ER_SSL_FIPS_MODE_ERROR, ssl_err_string);
+ return 1;
+ }
++#endif
+ if (SslAcceptorContext::singleton_init(opt_use_ssl)) return 1;
+
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
+--- a/sql/sys_vars.cc
++++ b/sql/sys_vars.cc
+@@ -4540,6 +4540,7 @@ static Sys_var_ulong Sys_max_execution_time(
+ HINT_UPDATEABLE SESSION_VAR(max_execution_time), CMD_LINE(REQUIRED_ARG),
+ VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1));
+
++#ifndef LIBRESSL_VERSION_NUMBER
+ static bool update_fips_mode(sys_var *, THD *, enum_var_type) {
+ char ssl_err_string[OPENSSL_ERROR_LENGTH] = {'\0'};
+ if (set_fips_mode(opt_ssl_fips_mode, ssl_err_string) != 1) {
+@@ -4550,15 +4551,30 @@ static bool update_fips_mode(sys_var *, THD *, enum_var_type) {
+ return false;
+ }
+ }
++#endif
+
++#if defined(LIBRESSL_VERSION_NUMBER)
++static const char *ssl_fips_mode_names[] = {"OFF", 0};
++#else
+ static const char *ssl_fips_mode_names[] = {"OFF", "ON", "STRICT", 0};
++#endif
+ static Sys_var_enum Sys_ssl_fips_mode(
+ "ssl_fips_mode",
+ "SSL FIPS mode (applies only for OpenSSL); "
++#ifndef LIBRESSL_VERSION_NUMBER
+ "permitted values are: OFF, ON, STRICT",
++#else
++ "permitted values are: OFF",
++#endif
+ GLOBAL_VAR(opt_ssl_fips_mode), CMD_LINE(REQUIRED_ARG, OPT_SSL_FIPS_MODE),
+ ssl_fips_mode_names, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG,
+- ON_CHECK(NULL), ON_UPDATE(update_fips_mode), NULL);
++ ON_CHECK(NULL),
++#ifndef LIBRESSL_VERSION_NUMBER
++ ON_UPDATE(update_fips_mode),
++#else
++ ON_UPDATE(NULL),
++#endif
++ NULL);
+
+ #if defined(HAVE_OPENSSL)
+ static Sys_var_bool Sys_auto_generate_certs(
+--- a/vio/viossl.cc
++++ b/vio/viossl.cc
+@@ -490,7 +490,7 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
+ #if !defined(DBUG_OFF)
+ {
+ STACK_OF(SSL_COMP) *ssl_comp_methods = NULL;
+- ssl_comp_methods = SSL_COMP_get_compression_methods();
++ ssl_comp_methods = (STACK_OF(SSL_COMP) *)SSL_COMP_get_compression_methods();
+ n = sk_SSL_COMP_num(ssl_comp_methods);
+ DBUG_PRINT("info", ("Available compression methods:\n"));
+ if (n == 0)
+@@ -498,7 +498,7 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
+ else
+ for (j = 0; j < n; j++) {
+ SSL_COMP *c = sk_SSL_COMP_value(ssl_comp_methods, j);
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ DBUG_PRINT("info", (" %d: %s\n", c->id, c->name));
+ #else /* OPENSSL_VERSION_NUMBER < 0x10100000L */
+ DBUG_PRINT("info",
+--- a/vio/viosslfactories.cc
++++ b/vio/viosslfactories.cc
+@@ -420,6 +420,7 @@ void ssl_start() {
+ }
+ }
+
++#ifndef LIBRESSL_VERSION_NUMBER
+ /**
+ Set fips mode in openssl library,
+ When we set fips mode ON/STRICT, it will perform following operations:
+@@ -473,6 +474,7 @@ EXIT:
+ @returns openssl current fips mode
+ */
+ uint get_fips_mode() { return FIPS_mode(); }
++#endif
+
+ long process_tls_version(const char *tls_version) {
+ const char *separator = ",";