1. 程式人生 > >執行專案連線Mysql時出現警告Establishing SSL connection without server's identity verification is not recommende

執行專案連線Mysql時出現警告Establishing SSL connection without server's identity verification is not recommende

     近期在跑一個專案的時候Idea的日誌窗口出現了下面的警告,該警告對執行測試的結果沒有影響,但是始終讓人不舒服,也不知道有沒有隱患,於是對該問題進行了瞭解和處理,警告內容如下:;

Thu Dec 20 12:50:09 CST 2018 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.

 

翻譯:

       不建議在沒有伺服器身份驗證的情況下建立SSL連線,根據MySQL 5.5.45+、5.6.26+和5.7.6+的要求,如果沒有設定顯式選項,則必須預設建立SSL連線。為了符合不使用SSL的現有應用程式,verifyServerCertificate屬性被設定為“false”。您需要通過設定useSSL=false顯式禁用SSL,或者設定useSSL=true併為伺服器證書驗證提供信任儲存。

        經過翻譯後是不是很清晰了,不建議在沒有伺服器身份驗證的情況下建立SSL連線,只是不建議,如果你執意這麼做的話呢,當然可以無視,那麼如果你接受了人家的建議,該怎麼解決這個問題呢?很簡單,在你連線資料庫的url後面加上引數即可,例如:

   jdbk:mysql://localhost:3306/testdb?useSSL=false

使用上述標紅的URL,即可解決該警告,標紅引數前面為你資料庫連線URL,如果有多個引數記得用&連線,例如

 jdbk:mysql://localhost:3306/testdb?characterEncoding=utf-8&useSSL=false