Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting to CockroachDB using SSL not working anymore after upgrading to JDBC driver version >= 42.3.2 #79999

Closed
georgian-micsa-form3 opened this issue Apr 15, 2022 · 5 comments
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-blathers-triaged blathers was able to find an owner

Comments

@georgian-micsa-form3
Copy link

georgian-micsa-form3 commented Apr 15, 2022

Describe the issue

After migrating to JDBC driver version >= 42.3.2, connection to our CockroachDB using SSL fails with following error: The server requested password-based authentication, but no password was provided by plugin null.

DB Version
Server version: CockroachDB CCL v21.1.7

JDBC Driver Version?
>= 42.3.2

Java Version?
1.8.0_312

To Reproduce

import java.sql.Connection;
import java.sql.DriverManager;

public class ConnectionTest {

    public static final String URL = "jdbc:postgresql://localhost:26257/some_db?" +
            "user=some_user" +
            "&ssl=true" +
            "&sslmode=verify-full" +
            "&sslcert=some_cert.crt" +
            "&sslkey=some_key.pk8" +
            "&sslrootcert=some_root_cert.crt";


    public static void main(String[] args) {
        try (Connection connection = DriverManager.getConnection(URL)) {
            System.out.println("Got connection: " + connection);
        } catch (Exception e) {
            System.out.println("Connection failure.");
            e.printStackTrace();
        }
    }
}

Expected behaviour
Using JDBC driver 42.3.1 and lower, we are able to get the connection.

Logs
Using 42.3.2, we get following error:

org.postgresql.util.PSQLException: The server requested password-based authentication, but no password was provided by plugin null
	at org.postgresql.core.v3.AuthenticationPluginManager.lambda$withEncodedPassword$0(AuthenticationPluginManager.java:110)
	at org.postgresql.core.v3.AuthenticationPluginManager.withPassword(AuthenticationPluginManager.java:81)
	at org.postgresql.core.v3.AuthenticationPluginManager.withEncodedPassword(AuthenticationPluginManager.java:107)
	at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:691)
	at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:180)
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:235)
	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
	at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:223)
	at org.postgresql.Driver.makeConnection(Driver.java:468)
	at org.postgresql.Driver.connect(Driver.java:267)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:270)

gz#12090

Jira issue: CRDB-15696

@georgian-micsa-form3 georgian-micsa-form3 added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Apr 15, 2022
@blathers-crl
Copy link

blathers-crl bot commented Apr 15, 2022

Hello, I am Blathers. I am here to help you get the issue triaged.

It looks like you have not filled out the issue in the format of any of our templates. To best assist you, we advise you to use one of these templates.

I have CC'd a few people who may be able to assist you:

  • @cockroachdb/bulk-io (found keywords: import)

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added A-disaster-recovery O-community Originated from the community X-blathers-triaged blathers was able to find an owner T-disaster-recovery labels Apr 15, 2022
@blathers-crl
Copy link

blathers-crl bot commented Apr 15, 2022

cc @cockroachdb/bulk-io

@shermanCRL shermanCRL added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) and removed A-disaster-recovery T-disaster-recovery labels Apr 15, 2022
@shermanCRL shermanCRL removed this from Triage in Disaster Recovery Backlog Apr 15, 2022
@rafiss
Copy link
Collaborator

rafiss commented Apr 18, 2022

Thanks for this report. Do you know if other versions of Java are affected too?

Looking at the PGJDBC changelog, nothing stands out in particular as a likely cause: https://jdbc.postgresql.org/documentation/changelog.html#version_42.3.2

@rafiss rafiss moved this from Triage to Smaller fixes/improvements in SQL Sessions - Deprecated Apr 18, 2022
@rafiss
Copy link
Collaborator

rafiss commented Apr 19, 2022

I tried locally using PGJDBC 42.3.2 and Java 1.8.0_292, and I was able to connect successfully.

@georgian-micsa-form3
Copy link
Author

Closing this issue: we debugged a bit more the problem and it's not an issue with neither CockroachDB nor PG JDBC driver.

It seems that our certificates were not generated correctly: on server side we were using ECDSA and on client side RSA and pgjdbc added some cert key type checking: pgjdbc/pgjdbc#2417 that was causing that error due to certificate type mismatch.

SQL Sessions - Deprecated automation moved this from Smaller fixes/improvements to Done Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-blathers-triaged blathers was able to find an owner
Projects
No open projects
Development

No branches or pull requests

4 participants