Обсуждение: md5 passwords in 7.2.3 ?
Just a quick check - are these supposed to work?
I'm running PostgreSQL 7.2.3 and connecting remotely - psql
seems to handle MD5 password auth (as specified in g_hba.conf) transparently,
but a very simple java app craps out :
--------------------------------------
import java.sql.*;
public class simpletest {
public static void main(String args[]) {
if ( args.length != 4 ) { usage(); }
try {
simpletest me = new simpletest();
me.connect(args);
} catch (Exception e) { e.printStackTrace(); }
}
public simpletest(){}
private void connect(String args[]) {
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException c) {
c.printStackTrace();
}
String user = args[0]; String pass = args[1];
String host = args[2]; String db = args[3];
String url = "jdbc:postgresql://" + host + "/" + db;
try {
Connection con = DriverManager.getConnection(url, user, pass);
} catch (SQLException s) {
s.printStackTrace();
}
}
private static void usage() {
System.err.println("usage\nsimpletest user pass host db");
System.exit(0);
}
}
--------------------------------------
Runing
java simpletest user pass host db
<names changed to protect the innocent>
gives me this error:
--------------------------------------
Something unusual has occured to cause the driver to fail. Please report this exception: Exception:
java.sql.SQLException:FATAL 1: Password authentication failed for user "user"
Stack Trace:
java.sql.SQLException: FATAL 1: Password authentication failed for user "user"
at org.postgresql.Connection.openConnection(Unknown Source)
at org.postgresql.Driver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:177)
at simpletest.connect(simpletest.java:38)
at simpletest.main(simpletest.java:14)
End of Stack Trace
at org.postgresql.Driver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:177)
at simpletest.connect(simpletest.java:38)
at simpletest.main(simpletest.java:14)
--------------------------------------
BUT it works (i.e. java exits without errors) if I setup another db
with a plaintext password in pg_shadow, so it seems related to MD5 .
Am I missing a step somewhere?
From a quick glance at the driver source, I think the driver
should be informed what password encoding to use by the server - in which case, I
wouldn't have thought the client *could* specify an encoding scheme.
I did check the archives and FAQ before posting, but couldn't tell if this was still
an issue...
--
Rasputin :: Jack of All Trades - Master of Nuns
You need a newer jdbc driver from jdbd.postgresql.org. It will work
with 7.2.3.
---------------------------------------------------------------------------
Rasputin wrote:
>
> Just a quick check - are these supposed to work?
>
> I'm running PostgreSQL 7.2.3 and connecting remotely - psql
> seems to handle MD5 password auth (as specified in g_hba.conf) transparently,
> but a very simple java app craps out :
>
> --------------------------------------
> import java.sql.*;
>
> public class simpletest {
>
> public static void main(String args[]) {
>
> if ( args.length != 4 ) { usage(); }
> try {
> simpletest me = new simpletest();
> me.connect(args);
> } catch (Exception e) { e.printStackTrace(); }
> }
>
> public simpletest(){}
>
> private void connect(String args[]) {
>
> try {
> Class.forName("org.postgresql.Driver");
> } catch (ClassNotFoundException c) {
> c.printStackTrace();
> }
>
> String user = args[0]; String pass = args[1];
> String host = args[2]; String db = args[3];
>
> String url = "jdbc:postgresql://" + host + "/" + db;
>
> try {
> Connection con = DriverManager.getConnection(url, user, pass);
> } catch (SQLException s) {
> s.printStackTrace();
> }
>
> }
>
> private static void usage() {
> System.err.println("usage\nsimpletest user pass host db");
> System.exit(0);
> }
> }
> --------------------------------------
>
> Runing
> java simpletest user pass host db
> <names changed to protect the innocent>
> gives me this error:
>
> --------------------------------------
> Something unusual has occured to cause the driver to fail. Please report this exception: Exception:
java.sql.SQLException:FATAL 1: Password authentication failed for user "user"
>
> Stack Trace:
>
> java.sql.SQLException: FATAL 1: Password authentication failed for user "user"
>
> at org.postgresql.Connection.openConnection(Unknown Source)
> at org.postgresql.Driver.connect(Unknown Source)
> at java.sql.DriverManager.getConnection(DriverManager.java:517)
> at java.sql.DriverManager.getConnection(DriverManager.java:177)
> at simpletest.connect(simpletest.java:38)
> at simpletest.main(simpletest.java:14)
> End of Stack Trace
>
> at org.postgresql.Driver.connect(Unknown Source)
> at java.sql.DriverManager.getConnection(DriverManager.java:517)
> at java.sql.DriverManager.getConnection(DriverManager.java:177)
> at simpletest.connect(simpletest.java:38)
> at simpletest.main(simpletest.java:14)
> --------------------------------------
>
> BUT it works (i.e. java exits without errors) if I setup another db
> with a plaintext password in pg_shadow, so it seems related to MD5 .
>
> Am I missing a step somewhere?
> >From a quick glance at the driver source, I think the driver
> should be informed what password encoding to use by the server - in which case, I
> wouldn't have thought the client *could* specify an encoding scheme.
>
> I did check the archives and FAQ before posting, but couldn't tell if this was still
> an issue...
>
>
>
> --
> Rasputin :: Jack of All Trades - Master of Nuns
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
* Bruce Momjian <pgman@candle.pha.pa.us> [1247 19:47]:
>
> You need a newer jdbc driver from jdbd.postgresql.org. It will work
> with 7.2.3.
Do you mean 7.3?
> Rasputin wrote:
> > I'm running PostgreSQL 7.2.3 and connecting remotely - psql
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--
Rasputin :: Jack of All Trades - Master of Nuns
* Rasputin <rasputin@idoru.mine.nu> [1255 14:55]: > * Bruce Momjian <pgman@candle.pha.pa.us> [1247 19:47]: > > > > You need a newer jdbc driver from jdbd.postgresql.org. It will work > > with 7.2.3. > > Do you mean 7.3? Sorry; just for the record, trying the 7.3 j2ee driver fixes my problem - thanks! -- Rasputin :: Jack of All Trades - Master of Nuns
* Dhek Bhun Kho <bhun@chello.nl> [1216 16:16]: > Hey Rasputin, > > Thanks for the info. Sorry I didn't read your too carefuly. No problem :) > Did you use a prebuilt 7.3 j2ee driver from a manual compilation of postgres? The prebuilt one - seems to fix my problem (I haven't even done a SELECT yet though, just wanted to setup a JDBC Realm in Tomcat to start with.....) > What's the big fuss about the new 7.3 version anyway? It fixes MD5 logins ? :) -- Rasputin :: Jack of All Trades - Master of Nuns
Rasputin wrote: > * Dhek Bhun Kho <bhun@chello.nl> [1216 16:16]: > > Hey Rasputin, > > > > Thanks for the info. Sorry I didn't read your too carefuly. > > No problem :) > > > Did you use a prebuilt 7.3 j2ee driver from a manual compilation of postgres? > > The prebuilt one - seems to fix my problem > (I haven't even done a SELECT yet though, just wanted to setup a JDBC Realm > in Tomcat to start with.....) > > > What's the big fuss about the new 7.3 version anyway? > > It fixes MD5 logins ? :) We fixed MD5 logins in jdbc many months ago, but after 7.2.3 was released, so you needed to get the newest one from jdbc.postgresql.org. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073