LoginSignup
2
0

More than 5 years have passed since last update.

Grails 3 + MySQLでrun-app時にSSL証明書で警告が出る場合の対処

Posted at

事象

Grailsのapplication.ymlにMySQLへの接続設定を記載した上で grails run-app すると、以下のような警告が出る。(起動自体は成功する)

PS C:\Users\KKZ\Git\SampleApp> grails run-app
| Running application...

Thu Apr 13 10:49:22 JST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. 
According to MySQL 5.5.45+,5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set.
For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'.
You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

使用環境

  • Windows7 64bit
  • posh-gvm
  • Grails 3.2.7
  • Groovy 2.4.9
  • MySQL 5.7.17
  • mysql-connector-java 6.0.6

原因

まあ、メッセージに書いてあるとおりで、

Thu Apr 13 10:49:22 JST 2017
警告:サーバーの身元確認なしにSSL接続を確立することはお勧めできません。
MySQL 5.5.45 +、5.6.26 +、および5.7.6+の要件明示的なオプションが設定されていない場合、デフォルトでSSL接続を確立する必要があります。
SSLを使用しない既存のアプリケーションに準拠するため、verifyServerCertificateプロパティは 'false'に設定されています。
useSSL = falseを設定してSSLを明示的に無効にするか、useSSL = trueに設定してサーバー証明書の検証にtruststoreを指定する必要があります。

5.7.6以降のMySQLではSSL接続がデフォルトになったので、明示的に指定しないとSSL接続するのですがちゃんとした証明書がないと警告が出る、という仕組みですね。

対処

本番環境ならちゃんとSSL証明書作った方がいいような気もしますが、とりあえずdevelopmentの環境なら、JDBCの接続文字列に ?useSSL=true&requireSSL=true を付与すればいいです。

conf/application.yml のdevelopmentのとこのJDBC接続文字列にパラメータを追加。

environments:
    development:
        dataSource:
            dbCreate: create-drop
            url: jdbc:mysql://localhost:3306/myschema?useSSL=false&requireSSL=false
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0