okumin / akka-persistence-sql-async

A journal and snapshot store plugin for akka-persistence using RDBMS.
Apache License 2.0
115 stars 26 forks source link

SSL mode is not being parsed #27

Open rolanddb opened 6 years ago

rolanddb commented 6 years ago

Hi, I'm struggling to set up a connection to a Postgresql database that requires ssl. I've configured the JDBC URL as: jdbc:postgresql://localhost:5432/datahub?sslmode=require However, the app fails with the following error:

[info] com.github.mauricio.async.db.postgresql.exceptions.GenericDatabaseException: ErrorMessage(fields=Map(Line -> 481, File -> auth.c, SQLSTATE -> 28000, Routine -> ClientAuthentication, Message -> SSL connection is required. Please specify SSL options and retry., Severity -> FATAL)) [info] at com.github.mauricio.async.db.postgresql.PostgreSQLConnection.onError(PostgreSQLConnection.scala:175) [info] at com.github.mauricio.async.db.postgresql.codec.PostgreSQLConnectionHandler.channelRead0(PostgreSQLConnectionHandler.scala:206)

This is strange, because the implementation of ParseURL seems correct. I've created a small test class with this line of code:

val configuration = com.github.mauricio.async.db.postgresql.util.URLParser.parse("postgresql://localhost:5432/datahub?sslmode=require") ^ this will parse the ssl mode correctly.

I've run a debugger session in IntelliJ and put a breakpoint on com.github.mauricio.async.db.postgresql.util.URLParser in the assembleConfiguration. But it seems this method is never invoked.

I put another breakpoint in PostgreSQLConnectionHandler, method initChannel (line 89) where I can view the parsed configuration. It turns out that database = Some(datahub?sslmode=require) and SSLConfiguration = (disable,None).

Can it be, that some other Parse method is being used? Can this be configured somewhere?

I spend quite some time debugging this, but I am unsure where to look further.

Versions: val akkaVersion = "2.5.3" "com.typesafe.akka" %% "akka-persistence" % akkaVersion, "com.okumin" %% "akka-persistence-sql-async" % "0.4.0", "com.github.mauricio" %% "postgresql-async" % "0.2.21",

okumin commented 6 years ago

@rolanddb This looks to be related to #19. If you need SSL support soon, would you give me PR?

rolanddb commented 6 years ago

@okumin We needed a quick solution/workaround, so we have set up stunnel. Unfortunately we cannot invest time in a PR at this time.