summaryrefslogtreecommitdiff
blob: e7e1a79e0ec2269973896960c3dceae949a340d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
diff -aurN a/cmake/ssl.cmake b/cmake/ssl.cmake
--- a/cmake/ssl.cmake	2019-09-20 04:30:51.000000000 -0400
+++ b/cmake/ssl.cmake	2019-10-15 12:07:03.527238024 -0400
@@ -214,13 +214,14 @@
         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
        OPENSSL_LIBRARY   AND
        CRYPTO_LIBRARY      AND
-       OPENSSL_MAJOR_VERSION STREQUAL "1"
+       OPENSSL_MAJOR_VERSION VERSION_GREATER_EQUAL "1"
       )
       SET(OPENSSL_FOUND TRUE)
       FIND_PROGRAM(OPENSSL_EXECUTABLE openssl
diff -aurN a/extra/libevent/openssl-compat.h b/extra/libevent/openssl-compat.h
--- a/extra/libevent/openssl-compat.h	2019-09-20 04:30:51.000000000 -0400
+++ b/extra/libevent/openssl-compat.h	2019-10-15 12:08:10.936049576 -0400
@@ -24,7 +24,6 @@
 #define BIO_set_init(b, val) (b)->init = (val)
 #define BIO_set_data(b, val) (b)->ptr = (val)
 #define BIO_set_shutdown(b, val) (b)->shutdown = (val)
-#define BIO_get_init(b) (b)->init
 #define BIO_get_data(b) (b)->ptr
 #define BIO_get_shutdown(b) (b)->shutdown
 
@@ -32,4 +31,8 @@
 
 #endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+#define BIO_get_init(b) (b)->init
+#endif
+
 #endif /* OPENSSL_COMPAT_H */
diff -aurN a/mysys/my_md5.cc b/mysys/my_md5.cc
--- a/mysys/my_md5.cc	2019-09-20 04:30:51.000000000 -0400
+++ b/mysys/my_md5.cc	2019-10-15 12:09:45.872784172 -0400
@@ -56,7 +56,9 @@
 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 /* LIBRESSL_VERSION_NUMBER */
   /* If fips mode is ON/STRICT restricted method calls will result into abort,
    * skipping call. */
   if (fips_mode == 0) {
diff -aurN 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
--- a/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/xcom_ssl_transport.c	2019-09-20 04:30:51.000000000 -0400
+++ b/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/xcom_ssl_transport.c	2019-10-15 12:15:01.414902035 -0400
@@ -329,6 +329,7 @@
   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 @@
 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 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();
diff -aurN a/plugin/x/client/xconnection_impl.cc b/plugin/x/client/xconnection_impl.cc
--- a/plugin/x/client/xconnection_impl.cc	2019-09-20 04:30:51.000000000 -0400
+++ b/plugin/x/client/xconnection_impl.cc	2019-10-15 12:18:03.522392929 -0400
@@ -521,6 +521,7 @@
   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 @@
 EXIT:
   return rc;
 }
+#endif
 
 XError Connection_impl::activate_tls() {
   if (nullptr == m_vio) return get_socket_error(SOCKET_ECONNRESET);
@@ -569,11 +571,13 @@
   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));
 
diff -aurN a/router/src/http/src/tls_client_context.cc b/router/src/http/src/tls_client_context.cc
--- a/router/src/http/src/tls_client_context.cc	2019-09-20 04:30:51.000000000 -0400
+++ b/router/src/http/src/tls_client_context.cc	2019-10-15 12:20:26.018994567 -0400
@@ -54,7 +54,7 @@
 
 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");
   }
diff -aurN a/router/src/http/src/tls_context.cc b/router/src/http/src/tls_context.cc
--- a/router/src/http/src/tls_context.cc	2019-09-20 04:30:51.000000000 -0400
+++ b/router/src/http/src/tls_context.cc	2019-10-15 12:22:15.244689211 -0400
@@ -91,7 +91,7 @@
       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
@@ -121,9 +121,11 @@
     default:
       // unknown, leave all disabled
       // fallthrough
+#ifdef TLS1_3_VERSION
     case TlsVersion::TLS_1_3:
       opts |= SSL_OP_NO_TLSv1_2;
       // fallthrough
+#endif
     case TlsVersion::TLS_1_2:
       opts |= SSL_OP_NO_TLSv1_1;
       // fallthrough
@@ -170,8 +172,10 @@
       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:
diff -aurN a/router/src/http/src/tls_server_context.cc b/router/src/http/src/tls_server_context.cc
--- a/router/src/http/src/tls_server_context.cc	2019-09-20 04:30:51.000000000 -0400
+++ b/router/src/http/src/tls_server_context.cc	2019-10-15 12:23:44.637439306 -0400
@@ -166,7 +166,8 @@
     }
 
   } 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
     /*
diff -aurN a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc	2019-09-20 04:30:51.000000000 -0400
+++ b/sql/mysqld.cc	2019-10-15 12:25:25.125158377 -0400
@@ -4797,7 +4797,7 @@
 
 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
diff -aurN a/sql/sys_vars.cc b/sql/sys_vars.cc
--- a/sql/sys_vars.cc	2019-09-20 04:30:51.000000000 -0400
+++ b/sql/sys_vars.cc	2019-10-15 12:31:09.656195203 -0400
@@ -4416,7 +4416,7 @@
     "milliseconds",
     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) {
@@ -4436,6 +4436,16 @@
     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);
+#else
+static const char *ssl_fips_mode_names[] = {"OFF", 0};
+static Sys_var_enum Sys_ssl_fips_mode(
+    "ssl_fips_mode",
+    "SSL FIPS mode (applies only for OpenSSL); "
+    "permitted values are: OFF",
+    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(NULL), NULL);
+#endif
 
 #if defined(HAVE_OPENSSL)
 static Sys_var_bool Sys_auto_generate_certs(
diff -aurN a/sql-common/client.cc b/sql-common/client.cc
--- a/sql-common/client.cc	2019-09-20 04:30:51.000000000 -0400
+++ b/sql-common/client.cc	2019-10-15 12:24:52.867248560 -0400
@@ -7715,7 +7715,7 @@
 #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);
diff -aurN a/vio/viossl.cc b/vio/viossl.cc
--- a/vio/viossl.cc	2019-09-20 04:30:51.000000000 -0400
+++ b/vio/viossl.cc	2019-10-15 12:33:17.966836499 -0400
@@ -490,7 +490,7 @@
 #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 @@
       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",
diff -aurN a/include/violite.h b/include/violite.h
--- a/include/violite.h	2019-09-20 04:30:51.000000000 -0400
+++ b/include/violite.h	2019-10-17 14:31:39.045842844 -0400
@@ -269,9 +269,11 @@
 
 long process_tls_version(const char *tls_version);
 
+#ifndef LIBRESSL_VERSION_NUMBER
 int set_fips_mode(const uint fips_mode, char *err_string);
 
 uint get_fips_mode();
+#endif
 
 struct st_VioSSLFd *new_VioSSLAcceptorFd(
     const char *key_file, const char *cert_file, const char *ca_file,
diff -aurN a/vio/viosslfactories.cc b/vio/viosslfactories.cc
--- a/vio/viosslfactories.cc	2019-10-17 14:27:32.672896538 -0400
+++ b/vio/viosslfactories.cc	2019-10-17 14:27:47.776954552 -0400
@@ -420,6 +420,7 @@
   }
 }
 
+#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 @@
   @returns openssl current fips mode
 */
 uint get_fips_mode() { return FIPS_mode(); }
+#endif
 
 long process_tls_version(const char *tls_version) {
   const char *separator = ",";