Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 459788 - dev-db/mysql-5.1.67 - mysqld refuses SSL certificate login
Summary: dev-db/mysql-5.1.67 - mysqld refuses SSL certificate login
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo Linux MySQL bugs team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-28 21:12 UTC by bgentoo
Modified: 2014-04-25 00:28 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
ca-cert.pem (ca-cert.pem,1.20 KB, text/plain)
2013-02-28 21:12 UTC, bgentoo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bgentoo 2013-02-28 21:12:38 UTC
Created attachment 340570 [details]
ca-cert.pem

Mysql compiled with ssl flag and certificates created according mysql documentation.

➜  openssl genrsa 2048 > ca-key.pem
......

➜  openssl req -new -x509 -nodes -days 3600 -key ca-key.pem -out ca-cert.pem
......

➜  openssl req -newkey rsa:2048 -days 3600 -nodes -keyout server-key.pem -out server-req.pem
.....

➜  openssl rsa -in server-key.pem -out server-key.pem
writing RSA key

➜  openssl x509 -req -in server-req.pem -days 3600 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem

➜  openssl req -newkey rsa:2048 -days 3600 -nodes -keyout client-key.pem -out client-req.pem

➜  openssl rsa -in client-key.pem -out client-key.pem
writing RSA key

➜  certs  openssl x509 -req -in client-req.pem -days 3600 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem

➜  openssl verify -CAfile ca-cert.pem server-cert.pem client-cert.pem
server-cert.pem: C = AU, ST = Some-State, O = Internet Widgits Pty Ltd
error 18 at 0 depth lookup:self signed certificate
OK
client-cert.pem: C = AU, ST = Some-State, O = Internet Widgits Pty Ltd
error 18 at 0 depth lookup:self signed certificate
OK

➜  certs  openssl verify -CAfile ca-cert.pem server-cert.pem client-cert.pem
server-cert.pem: C = AU, ST = Some-State, O = Internet Widgits Pty Ltd
error 18 at 0 depth lookup:self signed certificate
OK
client-cert.pem: C = AU, ST = Some-State, O = Internet Widgits Pty Ltd
error 18 at 0 depth lookup:self signed certificate
OK


Please find hereby all the details

➜  ~  equery u dev-db/mysql
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for dev-db/mysql-5.1.67:
 U I
 + + berkdb      : Adds support for sys-libs/db (Berkeley DB for MySQL)
 - - big-tables  : Make tables contain up to 1.844E+19 rows
 - - cluster     : Add support for NDB clustering (deprecated)
 + + community   : Enables the community features from upstream.
 - - debug       : Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see http://www.gentoo.org/proj/en/qa/backtraces.xml
 + + embedded    : Build embedded server (libmysqld)
 + + extraengine : Add support for alternative storage engines (Archive, CSV, Blackhole, Federated(X), Partition)
 - - latin1      : Use LATIN1 encoding instead of UTF8
 - - max-idx-128 : Raise the max index per table limit from 64 to 128
 - - minimal     : Install client programs only, no server
 - - pbxt        : Add experimental support for PBXT storage engine
 + + perl        : Adds optional support/bindings for the Perl language
 - - profiling   : Add support for statement profiling (requires USE=community).
 + + ssl         : Adds support for Secure Socket Layer connections
 - - static      : !!do not set this during bootstrap!! Causes binaries to be statically linked instead of dynamically
 - - test        : Install upstream testsuites for end use.
 - - xtradb      : Add experimental support for Percona's InnoDB replacement: XtraDB


➜ mysql> show variables like '%ssl%';
+---------------+--------------------------------------+
| Variable_name | Value                                |
+---------------+--------------------------------------+
| have_openssl  | YES                                  |
| have_ssl      | YES                                  |
| ssl_ca        | /var/lib/mysql/certs/ca-cert.pem     |
| ssl_capath    |                                      |
| ssl_cert      | /var/lib/mysql/certs/server-cert.pem |
| ssl_cipher    |                                      |
| ssl_key       | /var/lib/mysql/certs/server-key.pem  |
+---------------+--------------------------------------+

➜  ~  ll /var/lib/mysql/certs 
-rw-r--r-- 1 mysql mysql 1229 Feb 28 21:51 ca-cert.pem
-rw-r--r-- 1 mysql mysql 1679 Feb 28 21:51 ca-key.pem
-rw-r--r-- 1 mysql mysql 1099 Feb 28 21:52 client-cert.pem
-rw-r--r-- 1 mysql mysql 1679 Feb 28 21:51 client-key.pem
-rw-r--r-- 1 mysql mysql  956 Feb 28 21:51 client-req.pem
-rw-r--r-- 1 mysql mysql 1099 Feb 28 21:51 server-cert.pem
-rw-r--r-- 1 mysql mysql 1675 Feb 28 21:51 server-key.pem
-rw-r--r-- 1 mysql mysql  956 Feb 28 21:51 server-req.pem

And here is where the fun begins:
➜  ~  mysql -uroot --ssl-ca=/var/lib/mysql/certs/ca-cert.pem -p
Enter password: 
ERROR 2026 (HY000): SSL connection error

FYI: I've tested the same configuration using the same certificates with version 5.5.29-r1 without success, but it worked out on another OS.... (meaning that it's probably not a configuration issue)

Thanks!!!
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2013-03-01 16:20:12 UTC
Please post your `emerge --info' output in a comment.
Comment 2 bgentoo 2013-03-03 16:26:19 UTC
➜  ~  emerge --info
Portage 2.1.11.50 (default/linux/amd64/13.0, gcc-4.6.3, glibc-2.15-r3, 3.2.13-grsec-xxxx-grs-ipv6-64 x86_64)
=================================================================
System uname: Linux-3.2.13-grsec-xxxx-grs-ipv6-64-x86_64-Intel-R-_Atom-TM-_CPU_N2800_@_1.86GHz-with-gentoo-2.1
KiB Mem:     2028344 total,   1133792 free
KiB Swap:     525852 total,    524568 free
Timestamp of tree: Sun, 10 Feb 2013 00:15:01 +0000
ld GNU ld (GNU Binutils) 2.22
app-shells/bash:          4.2_p37
dev-lang/python:          2.7.3-r2, 3.2.3
dev-util/cmake:           2.8.9
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.11.8
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.69
sys-devel/automake:       1.11.6
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.6.3
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.6 (virtual/os-headers)
sys-libs/glibc:           2.15-r3
Repositories: gentoo
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /var/bind"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.4/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://mirror.ovh.net/gentoo-portage/"
USE="acl amd64 berkdb bzip2 cli cracklib crypt cxx dlz dri fortran gdbm iconv ipv6 mmx modules mudflap multilib ncurses nls openmp pam pcre readline session sse sse2 ssl tcpd unicode zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" PHP_TARGETS="php5-3" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="fbdev glint intel mach64 mga nouveau nv r128 radeon savage sis tdfx trident vesa via vmware dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 3 Brian Evans (RETIRED) gentoo-dev 2013-03-05 14:04:23 UTC
(In reply to comment #0)

> ➜  ~  ll /var/lib/mysql/certs 
> -rw-r--r-- 1 mysql mysql 1229 Feb 28 21:51 ca-cert.pem
> -rw-r--r-- 1 mysql mysql 1679 Feb 28 21:51 ca-key.pem
> -rw-r--r-- 1 mysql mysql 1099 Feb 28 21:52 client-cert.pem
> -rw-r--r-- 1 mysql mysql 1679 Feb 28 21:51 client-key.pem
> -rw-r--r-- 1 mysql mysql  956 Feb 28 21:51 client-req.pem
> -rw-r--r-- 1 mysql mysql 1099 Feb 28 21:51 server-cert.pem
> -rw-r--r-- 1 mysql mysql 1675 Feb 28 21:51 server-key.pem
> -rw-r--r-- 1 mysql mysql  956 Feb 28 21:51 server-req.pem
> 
> And here is where the fun begins:
> ➜  ~  mysql -uroot --ssl-ca=/var/lib/mysql/certs/ca-cert.pem -p
> Enter password: 
> ERROR 2026 (HY000): SSL connection error
> 

What permissions are on /var/lib/mysql itself?
By default they are:
drwxr-x--- 2 mysql mysql 4096 Feb 26 16:35 /var/lib/mysql

If the client is not in the mysql group, they would get denied reading the ca-cert.pem due to the folder permission.

> FYI: I've tested the same configuration using the same certificates with
> version 5.5.29-r1 without success, but it worked out on another OS....
> (meaning that it's probably not a configuration issue)
> 
> Thanks!!!
Comment 4 bgentoo 2013-03-06 07:32:42 UTC
The permissions are correct:
drwxr-x--- 7 mysql  mysql   4096 Feb 28 20:27 mysql

And I use mysql as root... I also though about a permission issue but even when I put all the certificates in /tmp with a really permissive rights (777) I have the same issue.
Comment 5 Brian Evans (RETIRED) gentoo-dev 2013-03-06 14:58:50 UTC
Cannot repeat here. Instructions listed in Comment 0 used to create the server cert. Did not bother with the "client certs" as they are not used for this test.
------
dev-db/mysql-5.5.29

~ # mysql --ssl-ca=/etc/mysql/certs/ca-cert.pem

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.29 Source distribution

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.5.29, for Linux (x86_64) using readline 6.2

Connection id:          1
Current database:
Current user:           root@localhost
SSL:                    Cipher in use is DHE-RSA-AES256-SHA
Current pager:          /usr/bin/less
Using outfile:          ''
Using delimiter:        ;
Server version:         5.5.29 Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /var/run/mysqld/mysqld.sock
Uptime:                 9 sec

Threads: 1  Questions: 4  Slow queries: 0  Opens: 33  Flush tables: 1  Open tables: 26  Queries per second avg: 0.444
--------------

mysql> show variables like '%ssl%';
+---------------+----------------------------------+
| Variable_name | Value                            |
+---------------+----------------------------------+
| have_openssl  | YES                              |
| have_ssl      | YES                              |
| ssl_ca        | /etc/mysql/certs/ca-cert.pem     |
| ssl_capath    |                                  |
| ssl_cert      | /etc/mysql/certs/server-cert.pem |
| ssl_cipher    |                                  |
| ssl_key       | /etc/mysql/certs/server-key.pem  |
+---------------+----------------------------------+
7 rows in set (0.00 sec)

------
dev-db/mysql-5.1.67-r1

~ # mysql --ssl-ca=/etc/mysql/certs/ca-cert.pem

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.67 Gentoo Linux mysql-5.1.67-r1

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.1.67, for pc-linux-gnu (x86_64) using readline 5.1

Connection id:          1
Current database:
Current user:           root@localhost
SSL:                    Cipher in use is DHE-RSA-AES256-SHA
Current pager:          /usr/bin/less
Using outfile:          ''
Using delimiter:        ;
Server version:         5.1.67 Gentoo Linux mysql-5.1.67-r1
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /var/run/mysqld/mysqld.sock
Uptime:                 15 sec

Threads: 1  Questions: 4  Slow queries: 0  Opens: 15  Flush tables: 1  Open tables: 8  Queries per second avg: 0.266
--------------

mysql> show variables like '%ssl%';
+---------------+----------------------------------+
| Variable_name | Value                            |
+---------------+----------------------------------+
| have_openssl  | YES                              |
| have_ssl      | YES                              |
| ssl_ca        | /etc/mysql/certs/ca-cert.pem     |
| ssl_capath    |                                  |
| ssl_cert      | /etc/mysql/certs/server-cert.pem |
| ssl_cipher    |                                  |
| ssl_key       | /etc/mysql/certs/server-key.pem  |
+---------------+----------------------------------+
7 rows in set (0.00 sec)
Comment 6 bgentoo 2013-03-06 15:21:16 UTC
Can you please tell what are the use flag that you used since I can reproduce it on all the machines but cannot make it work on any?
Comment 7 Brian Evans (RETIRED) gentoo-dev 2013-03-06 15:37:26 UTC
(In reply to comment #6)
> Can you please tell what are the use flag that you used since I can
> reproduce it on all the machines but cannot make it work on any?

The same flags as you except with latin1 on.  That flag only changes the config file and does not affect the build.

Out of curiosity, did you build mysql with the broken openssl-1.0.1d and not rebuild after it was masked?
Comment 8 bgentoo 2013-03-07 07:38:30 UTC
No I'm still using openssl-1.0.1c