Connection Java-MySql : Public Key Retrieval is not allowed
You should add client option to your mysql-connector allowPublicKeyRetrieval=true
to allow the client to automatically request the public key from the server. Note that allowPublicKeyRetrieval=True
could allow a malicious proxy to perform a MITM attack to get the plaintext password, so it is False by default and must be explicitly enabled.
https://mysql-net.github.io/MySqlConnector/connection-options/
you could also try adding useSSL=false
when you use it for testing/develop purposes
example:
jdbc:mysql://localhost:3306/db?allowPublicKeyRetrieval=true&useSSL=false
For DBeaver users:
Right click your connection, choose "Edit Connection"
On the "Connection settings" screen (main screen) click on "Edit Driver Settings"
Click on "Connection properties", (In recent versions it named "Driver properties")
Right click the "user properties" area and choose "Add new property"
Add two properties: "useSSL" and "allowPublicKeyRetrieval"
Set their values to "false" and "true" by double clicking on the "value" column
Use jdbc url
as :
jdbc:mysql://localhost:3306/Database_dbName?allowPublicKeyRetrieval=true&useSSL=False;
PortNo: 3306
can be different in your configuation
When doing this from DBeaver I had to go to "Connection settings" -> "SSL" tab and then :
- uncheck the "Verify server certificate"
- check the "Allow public key retrival"
This is how it looks like.
Note that this is suitable for local development only.