mita2 database life

主にMySQLに関するメモです

MySQLでワイルドカード証明書が扱えないという話をしたらすぐ扱えるようになった件

07/23日の日本MySQLユーザ会で、MySQLSSLや透過的暗号化について発表してきました。



発表の中で、 SSLワイルドカード証明書がうまく扱えず、大量にサーバを管理するときは大変。。。という話をしました。 ところが、発表してから4日後にリリースされた、MySQL 8.0.12でワイルドカード証明書が扱えるようになってました!!

8.0.11 クライアントだとサーバ証明書ワイルドカード証明書だと、--ssl-mode=VERIFY_IDENTITYで通らない
$ mysql --version
mysql Ver 8.0.11 for Linux on x86_64 (MySQL Community Server - GPL)

$ mysql -h db01.example.jp --ssl-ca=ca.pem --ssl-mode=VERIFY_IDENTITY -unativeuser -p
ERROR 2026 (HY000): SSL connection error: SSL certificate validation failure

8.0.12だと、無事通る。
$ mysql --version
mysql Ver 8.0.12 for Linux on x86_64 (MySQL Community Server - GPL)

$ mysql -h db01.example.jp --ssl-ca=ca.pem --ssl-mode=VERIFY_IDENTITY -unativeuser -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1103
Server version: 8.0.11 MySQL Community Server - GPL

Copyright (c) 2000, 2018, 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> exit
Bye


booking.com の方がコントリビュートされたようです。
https://github.com/mysql/mysql-server/pull/196

リリースノートにはワイルドカード証明書が扱えるようになったとは書かれておらず、SANが扱えるようになったと記載されています。
Previously, for the --ssl-mode=VERIFY_IDENTITY option, the client checked whether the host name that it used for connecting matched the Common Name value in the certificate but not the Subject Alternative Name value. Now, if the client uses OpenSSL 1.0.2 or higher, the client checks whether the host name matches either the Subject Alternative Name value or the Common Name value in the server certificate. Thanks to Daniël van Eeden for a patch on which this change was based. (Bug #16211011, Bug #68052, Bug #27511233, Bug #89578)

SSL証明書には複数のドメインを扱うための、Subject Alternative Nameという領域があります。 今回の修正で、名前のチェックをMySQL独自の実装からopensslのライブラリを使うように置き換えられました。
これによって、SANだけでなく、ワイルドカード証明書も期待したとおりの動きになりました。

めでたしめでたし。