Subject: [pgjdbc/pgjdbc] issue #3461: ongres ScramException issue prevents use of postgresql-42.7.2.jar with scram-sha-256

From: "DavidGradwell (@DavidGradwell)" <[email-masked]>
Date: Fri, 13 Dec 2024 14:40:30 +0000

P
Note that all our servers have pg_hba.conf files containing rows like:

# IPv4 local connections:
host    all             all             127.0.0.1/32            scram-sha-256
host    all             all             192.168.1.15/32            scram-sha-256

We moved to scram-sha-256 some years ago with no problems.

We have twenty or more applications.  As part of regular maintenance, we replaced the jdbc driver postgresql-42.5.4.jar that we had been using for a year or more very successfully by the latest postgresql-42.7.2.jar.

All our logon code in all applications now invariably throws:

com/ongres/scram/common/exception/ScramException

The exception is

java.lang.NoClassDefFoundError: com/ongres/scram/common/exception/ScramException
	at org.postgresql.core.v3.ConnectionFactoryImpl.lambda$doAuthentication$5(ConnectionFactoryImpl.java:864)
	at org.postgresql.core.v3.AuthenticationPluginManager.withPassword(AuthenticationPluginManager.java:82)
	at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:851)
	at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:213)
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:268)
	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:54)
	at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:273)
	at org.postgresql.Driver.makeConnection(Driver.java:446)
	at org.postgresql.Driver.connect(Driver.java:298)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:190)
	at com.gradwell.dbAppCore.ConnectInfo.doConnect(ConnectInfo.java:136)
etc.

This is 100% reproducible in many Java applications.  Reverting the application build to using postgresql-42.5.4.jar and the problem goes away.

It does look as though other people have hit this issue or related exceptions.   As part of our research we added ongres/scram-client-3.1.jar and ongres/common-2.1.jar to the build but that does not help.  I found that https://stackoverflow.com/questions/62807717/how-can-i-solve-postgresql-scram-authentication-problem gave me enough clues to decide to go back to the older jdbc driver.

I would be happy to alpha & beta test the version of the jdbc driver that fixes this problem.

The following version details may be helpful.

Product Version: Apache NetBeans IDE 23 
Java: 17.0.13; OpenJDK 64-Bit Server VM 17.0.13+11-LTS 
Runtime: OpenJDK Runtime Environment 17.0.13+11-LTS 
System: Mac OS X version 15.1.1 running on aarch64; 

The machine is an M4 MacMini.

---

From: "jorsol (@jorsol)" <[email-masked]>
Date: Fri, 13 Dec 2024 14:51:37 +0000

Hi @DavidGradwell , to troubleshoot the issue, could you clarify how or where are you downloading the jdbc driver? Is it from Maven, GH releases, JDBC Website?

Now the second thing, could you please try with the latest version 42.7.4?

I can't see at all how the linked StackOverflow question is related to the JDBC driver, can you clarify how is related?

---

From: "DavidGradwell (@DavidGradwell)" <[email-masked]>
Date: Mon, 16 Dec 2024 12:59:48 +0000

Jorge,

I usually download from https://github.com/pgjdbc/pgjdbc/releases when a new release is announced.  The jar is then explicitly included in each of my app builds.  I do have Maven references in some lower level libraries built using Maven.  However, my top levels have to be built using Ant with explicit libraries if I am to successfully use the Apple Notarization process.

I have checked that if I remove the postgres jdbc jar from the top level app build I get
java.lang.ClassNotFoundException: org.postgresql.Driver at the first call to postgres, so I am not loading another version from somewhere else.

I downloaded postgresql-42.7.4.jar today, replaced the old driver and that now works fine.

Thank goodness.  I will now move to test with all my apps with 42.7.4 and report any further issues, but hopefully none will be found !

David Gradwell

From: Jorge Solórzano ***@***.***>
Date: Friday, 13 December 2024 at 14:52
To: pgjdbc/pgjdbc ***@***.***>
Cc: David Gradwell ***@***.***>, Mention ***@***.***>
Subject: Re: [pgjdbc/pgjdbc] ongres ScramException issue prevents use of postgresql-42.7.2.jar with scram-sha-256 (Issue #3461)
You don't often get email from ***@***.*** Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>

Hi @DavidGradwell<https://github.com/DavidGradwell> , to troubleshoot the issue, could you clarify how or where are you downloading the jdbc driver? Is it from Maven, GH releases, JDBC Website?

—
Reply to this email directly, view it on GitHub<https://github.com/pgjdbc/pgjdbc/issues/3461#issuecomment-2541628218>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABNUWKJIRSOEQYICR4YK7TT2FLYBBAVCNFSM6AAAAABTSD4NKGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBRGYZDQMRRHA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>

---

From: "jorsol (@jorsol)" <[email-masked]>
Date: Mon, 16 Dec 2024 13:10:24 +0000

> I downloaded postgresql-42.7.4.jar today, replaced the old driver and that now works fine. Thank goodness. I will now move to test with all my apps with 42.7.4 and report any further issues, but hopefully none will be found !

Great, if you find any further issues please open a new issue.

Can this issue be closed now?

---

From: "DavidGradwell (@DavidGradwell)" <[email-masked]>
Date: Mon, 16 Dec 2024 13:12:23 +0000

Indeed yes.

I won’t be going back to the troublesome driver !

Best wishes for the New Year.

David Gradwell

Date: Monday, 16 December 2024 at 13:10

—
Reply to this email directly, view it on GitHub<https://github.com/pgjdbc/pgjdbc/issues/3461#issuecomment-2545594886>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABNUWKLPZFGVH4V2QB22PS32F3GNPAVCNFSM6AAAAABTSD4NKGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBVGU4TIOBYGY>.
You are receiving this because you were mentioned.Message ID: ***@***.***>

---

From: "jorsol (@jorsol)" <[email-masked]>
Date: Mon, 16 Dec 2024 13:16:42 +0000

Thank you, Best wishes for the New Year to you as well!