Skip to content

Commit dbbe747

Browse files
committed
Bug #21221862 NEWEST RHEL/CENTOS OPENSSL UPDATE BREAKS MYSQL DHE CIPHERS
Description: The newest RHEL/CentOS/SL 6.6 openssl package (1.0.1e-30.el6_6.9; published around 6/4/2015) contains a fix for LogJam. RedHat's fix for this was to limit the use of any SSL DH key sizes to a minimum of 768 bits. This breaks any DHE SSL ciphers for MySQL clients as soon as you install the openssl update, since in vio/viosslfactories.c, the default DHPARAM is a 512 bit one. This cannot be changed in configuration/runtime; and needs a recompile. Because of this the client connection with --ssl-cipher=DHE-RSA-AES256-SHA is not able to connect the server. Analysis: Openssl has changed Diffie-Hellman key from the 512 to 1024 due to some reasons(please see the details at http://openssl.org/news/secadv_20150611.txt) Because of this the client with DHE cipher is failing to connect the server. This change took place from the openssl-1.0.1n onwards. Fix: Similar bug fix is already pushed to mysql-5.7 under bug#18367167. Hence we backported the same fix to mysql-5.5 and mysql-5.6.
1 parent 0dedf55 commit dbbe747

2 files changed

Lines changed: 56 additions & 17 deletions

File tree

include/violite.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -128,7 +128,7 @@ enum enum_ssl_init_error
128128
{
129129
SSL_INITERR_NOERROR= 0, SSL_INITERR_CERT, SSL_INITERR_KEY,
130130
SSL_INITERR_NOMATCH, SSL_INITERR_BAD_PATHS, SSL_INITERR_CIPHERS,
131-
SSL_INITERR_MEMFAIL, SSL_INITERR_LASTERR
131+
SSL_INITERR_MEMFAIL, SSL_INITERR_DHFAIL, SSL_INITERR_LASTERR
132132
};
133133
const char* sslGetErrString(enum enum_ssl_init_error err);
134134

vio/viosslfactories.c

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,56 @@
2020
static my_bool ssl_algorithms_added = FALSE;
2121
static my_bool ssl_error_strings_loaded= FALSE;
2222

23-
static unsigned char dh512_p[]=
23+
/*
24+
Diffie-Hellman key.
25+
Generated using: >openssl dhparam -5 -C 2048
26+
27+
-----BEGIN DH PARAMETERS-----
28+
MIIBCAKCAQEAil36wGZ2TmH6ysA3V1xtP4MKofXx5n88xq/aiybmGnReZMviCPEJ
29+
46+7VCktl/RZ5iaDH1XNG1dVQmznt9pu2G3usU+k1/VB4bQL4ZgW4u0Wzxh9PyXD
30+
glm99I9Xyj4Z5PVE4MyAsxCRGA1kWQpD9/zKAegUBPLNqSo886Uqg9hmn8ksyU9E
31+
BV5eAEciCuawh6V0O+Sj/C3cSfLhgA0GcXp3OqlmcDu6jS5gWjn3LdP1U0duVxMB
32+
h/neTSCSvtce4CAMYMjKNVh9P1nu+2d9ZH2Od2xhRIqMTfAS1KTqF3VmSWzPFCjG
33+
mjxx/bg6bOOjpgZapvB6ABWlWmRmAAWFtwIBBQ==
34+
-----END DH PARAMETERS-----
35+
*/
36+
static unsigned char dh2048_p[]=
2437
{
25-
0xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,0xD0,0xE4,0xAF,0x75,
26-
0x6F,0x4C,0xCA,0x92,0xDD,0x4B,0xE5,0x33,0xB8,0x04,0xFB,0x0F,
27-
0xED,0x94,0xEF,0x9C,0x8A,0x44,0x03,0xED,0x57,0x46,0x50,0xD3,
28-
0x69,0x99,0xDB,0x29,0xD7,0x76,0x27,0x6B,0xA2,0xD3,0xD4,0x12,
29-
0xE2,0x18,0xF4,0xDD,0x1E,0x08,0x4C,0xF6,0xD8,0x00,0x3E,0x7C,
30-
0x47,0x74,0xE8,0x33,
38+
0x8A, 0x5D, 0xFA, 0xC0, 0x66, 0x76, 0x4E, 0x61, 0xFA, 0xCA, 0xC0, 0x37,
39+
0x57, 0x5C, 0x6D, 0x3F, 0x83, 0x0A, 0xA1, 0xF5, 0xF1, 0xE6, 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0xC8, 0xCA, 0x35, 0x58, 0x7D, 0x3F, 0x59, 0xEE,
55+
0xFB, 0x67, 0x7D, 0x64, 0x7D, 0x8E, 0x77, 0x6C, 0x61, 0x44, 0x8A, 0x8C,
56+
0x4D, 0xF0, 0x12, 0xD4, 0xA4, 0xEA, 0x17, 0x75, 0x66, 0x49, 0x6C, 0xCF,
57+
0x14, 0x28, 0xC6, 0x9A, 0x3C, 0x71, 0xFD, 0xB8, 0x3A, 0x6C, 0xE3, 0xA3,
58+
0xA6, 0x06, 0x5A, 0xA6, 0xF0, 0x7A, 0x00, 0x15, 0xA5, 0x5A, 0x64, 0x66,
59+
0x00, 0x05, 0x85, 0xB7,
3160
};
3261

33-
static unsigned char dh512_g[]={
34-
0x02,
62+
static unsigned char dh2048_g[]={
63+
0x05,
3564
};
3665

37-
static DH *get_dh512(void)
66+
static DH *get_dh2048(void)
3867
{
3968
DH *dh;
4069
if ((dh=DH_new()))
4170
{
42-
dh->p=BN_bin2bn(dh512_p,sizeof(dh512_p),NULL);
43-
dh->g=BN_bin2bn(dh512_g,sizeof(dh512_g),NULL);
71+
dh->p=BN_bin2bn(dh2048_p,sizeof(dh2048_p),NULL);
72+
dh->g=BN_bin2bn(dh2048_g,sizeof(dh2048_g),NULL);
4473
if (! dh->p || ! dh->g)
4574
{
4675
DH_free(dh);
@@ -81,7 +110,8 @@ ssl_error_string[] =
81110
"Private key does not match the certificate public key",
82111
"SSL_CTX_set_default_verify_paths failed",
83112
"Failed to set ciphers to use",
84-
"SSL_CTX_new failed"
113+
"SSL_CTX_new failed",
114+
"SSL_CTX_set_tmp_dh failed"
85115
};
86116

87117
const char*
@@ -258,8 +288,17 @@ new_VioSSLFd(const char *key_file, const char *cert_file,
258288
}
259289

260290
/* DH stuff */
261-
dh=get_dh512();
262-
SSL_CTX_set_tmp_dh(ssl_fd->ssl_context, dh);
291+
dh= get_dh2048();
292+
if (SSL_CTX_set_tmp_dh(ssl_fd->ssl_context, dh) == 0)
293+
{
294+
*error= SSL_INITERR_DHFAIL;
295+
DBUG_PRINT("error", ("%s", sslGetErrString(*error)));
296+
report_errors();
297+
DH_free(dh);
298+
SSL_CTX_free(ssl_fd->ssl_context);
299+
my_free(ssl_fd);
300+
DBUG_RETURN(0);
301+
}
263302
DH_free(dh);
264303

265304
DBUG_PRINT("exit", ("OK 1"));

0 commit comments

Comments
 (0)