Error "Public Key Retrieval is not allowed" appears even with "allowPublicKeyRetrieval=true"

SoReT3 years ago

Hello!

Sorry for posting for what appears to be an issue that is already solved:
https://www.traccar.org/forums/topic/how-to-resolve-error-public-key-retrieval-is-not-allowed/

I have added "allowPublicKeyRetrieval=true" and I still get the following:

Caused by: com.mysql.cj.exceptions.UnableToConnectException: Public Key Retrieval is not allowed
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
    at com.mysql.cj.protocol.a.authentication.CachingSha2PasswordPlugin.nextAuthenticationStep(CachingSha2PasswordPlugin.java:130)

    ... 22 more

I have even added "useSSL=false" twice, exactly as it is in the example above from Pedro, but obviously without result. But I always make sure I try everything before I post (even the dumbest things).

Everywhere I look, the "issue" seems to only be solvable by adding "allowPublicKeyRetrieval=true" and "useSSL=false".

I would have liked to post my configuration file here but the markdown syntax seems to not like XML format. But I did make extra sure that the syntax was correct. In fact, I tried the 'logger.level' set to all, and it's working (although I can't make out a lot from the logs themselves).

I also tried getting the wrapper logs but I can't find them inside the Alpine Linux Docker image. Maybe they are disabled for Docker? For example, generic logs in MySQL are disabled by default in the Docker image.

I am using the Docker latest version of both Traccar and MySQL. I can confirm that network configuration is ok because I accidentally specified a non-existent user and in that case I got an "access denied" error from the server.

Any idea on how I can track down this issue?
Please help :) Thank you!

Anton Tananaev3 years ago

Setting allowPublicKeyRetrieval=true and useSSL=false should help. Are you sure the issue is not with config (e.g. it's reset or something)?

SoReT3 years ago

Thank you very much for your prompt reply!

I have run the Docker container as the maintainer suggests, with the following volume:
-v /var/docker/traccar/traccar.xml:/opt/traccar/conf/traccar.xml:ro
So that I can have direct access to the XML file.

I think it is taking it correctly because if I specify for example a wrong server then the error will say something like "host not found" so I assume that the database URL it's taking it okay.

Here is exactly the combination of 'database.url' that I'm using right now (after trying many combinatios: notice the double "useSSL" as per Pedro's indication).

<entry key='database.url'>jdbc:mysql://mysql:3306/traccar?allowPublicKeyRetrieval=true&amp;useSSL=false&amp;serverTimezone=UTC&amp;useSSL=false&amp;allowMultiQueries=true&amp;autoReconnect=true&amp;useUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=''</entry>

Do you think there is some other information that I can provide with to help me diagnose this issue?

Thank you again :)

Anton Tananaev3 years ago

Don't really have any other ideas.

Adding useSSL=false is silly, I think. I don't this it would help.

SoReT3 years ago

I know there has to be something I'm missing, but I just tried spending some time again today on this and things just started working without having to do anything.
I have even tried removing the "allowPublicKeyRetrieval" thing and that even works now. Believe me when I say I've spent a long time looking for what has changed since the other day, and I don't see anything. Nothing has been updated, there aren't any new tags in DockerHub, I have reviewed the command history, etc....
Anyway, thank you for your help :)

SoReT3 years ago

Sorry to reopen the case. I still don't know why it started working two weeks ago, but I had to reboot the server at one point since then, and the problem came back, this time for good, no matter what I do. Same exact thing.
Maybe the issue is in the MySQL? Maybe a specific setting needs to be set? :(
Thank you :)

SoReT3 years ago

I think I know where the problem might be. I had created a new user for the database like so

mysql> create user traccar@'%' identified by 'password';
mysql> grant all privileges on traccar.* to traccar@'%';

And while it's working fine with MySQL Workbench (I even tried editing the tables, adding & deleting rows, etc), when I try to use that user with Traccar, I get the error that I posted at the very beginning.

I've been trying to figure out if it has something to do with privileges or roles. Maybe you know the answer for this?

Thank you again, as always!

Anton Tananaev3 years ago

Try to explicitly specify mysql_native_password.

SoReT3 years ago

Hello!
I solved the issue by using MariaDB.
No problems so far!
Thank you so much!