Dongjun Lim
Dongjun Lim

Reputation: 1

Using r2dbc-postgresql for CockroachDB result in authentication failure: "Password must not be null"

I'm trying to connect to a CockroachDB cluster using r2dbc-postgresql, (I've tried both org.postgresql as well as io.r2dbc) as well as spring-data-r2dbc from my reactive Kotlin app - which is running on spring webflux. When attempting to connect, It fails to authenticate first because the selected connection strategy is SingleHostConnection which uses username and password. I thought it'd fall back to SSL after but it throws an error and discards. Any idea how to trigger SSL connection explicitly? OR does r2dbc require strictly UsernameAndPassword authentication?

When I was debugging, I noticed that it was using ReactorNettyClient.connect method as its default connection function but once SingleHostConnectionFunction's connect method started executing, it never hit. Seems like that's where it needs to go.

Upvotes: 0

Views: 145

Answers (1)

aaron
aaron

Reputation: 43083

I thought it'd fall back to SSL after but it throws an error and discards. Any idea how to trigger SSL connection explicitly?

Using r2dbc-postgresql driver, you need to specify ?sslmode=allow to fall back to SSL.

Consider specifying:

  • ?sslmode=prefer to try SSL connection first, and fall back to non-SSL.
  • ?sslmode=require to trigger SSL connection explicitly.

PostgreSQL libpq doc describes other SSL modes: disable, verify-ca, verify-full

Explanation

PostgreSQL libpq doc states The default value for sslmode is prefer, but driver implementations may have a different default value:

Driver Default value for sslmode Source
pgjdbc PREFER SslMode.java#L70
r2dbc-postgresql DISABLE PostgresqlConnectionConfiguration.java#L407

Upvotes: 0

Related Questions