GSSAPI/KRB5 and JDBC (again)

From: "Peter Koczan" <pjkoczan(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: GSSAPI/KRB5 and JDBC (again)
Date: 2008-07-24 23:04:30
Message-ID: 4544e0330807241604ye974d07x34408ac3cc11cf3e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello again, I've finally had time to test out Kris' patches for
GSSAPI support in the Postgres 8.3 JDBC
(http://ejurka.com/pgsql/jars/gss), but I'm not quite getting it
right, it seems. The JDBC built fine, and it connects properly via
MD5, but it can't get a GSSAPI connection, even with Kris' advice in
http://archives.postgresql.org/pgsql-jdbc/2008-01/msg00154.php

$ export CLASSPATH=/s/postgresql-8.3.3/src/postgresql-jdbc-8.3-603.src/jars/postgresql.jar:.
$ java -Djava.security.auth.login.config=login.conf Jdbc
Uncaught exception in main...
org.postgresql.util.PSQLException: GSS Authentication failed
at org.postgresql.gss.MakeGSS.authenticate(MakeGSS.java:36)
at org.postgresql.Driver.makeGSS(Driver.java:775)
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:373)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:98)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:124)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:29)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:386)
at org.postgresql.Driver.connect(Driver.java:260)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at Jdbc.main(Jdbc.java:15)
Caused by: javax.security.auth.login.LoginException: Integrity check
on decrypted field failed (31)
at com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(Krb5LoginModule.java:696)
at com.sun.security.auth.module.Krb5LoginModule.login(Krb5LoginModule.java:542)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
at org.postgresql.gss.MakeGSS.authenticate(MakeGSS.java:30)
... 13 more
Caused by: KrbException: Integrity check on decrypted field failed (31)
at sun.security.krb5.internal.crypto.DesCbcEType.decrypt(DesCbcEType.java:154)
at sun.security.krb5.internal.crypto.DesCbcCrcEType.decrypt(DesCbcCrcEType.java:30)
at sun.security.krb5.internal.crypto.DesCbcCrcEType.decrypt(DesCbcCrcEType.java:77)
at sun.security.krb5.EncryptedData.decrypt(EncryptedData.java:168)
at sun.security.krb5.KrbAsRep.<init>(KrbAsRep.java:87)
at sun.security.krb5.KrbAsReq.getReply(KrbAsReq.java:449)
at sun.security.krb5.Credentials.sendASRequest(Credentials.java:406)
at sun.security.krb5.Credentials.acquireTGT(Credentials.java:355)
at com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(Krb5LoginModule.java:662)
... 25 more

login.conf simply contains:

pgjdbc {
com.sun.security.auth.module.Krb5LoginModule required useTicketCache=true;
};

Jdbc.java is just

import java.sql.*; // import the JDBC
import java.util.*;

public class Jdbc {
public static void main (String[] args) {
try {
Class.forName("org.postgresql.Driver"); // Load the PostgreSQL
JDBC driver

// Connect to the database

Properties props = new Properties();
props.setProperty("user", "koczan");
props.setProperty("password", "fakepw");
// props.setProperty("ssl", "true");
Connection conn =
DriverManager.getConnection("jdbc:postgresql://mitchell.cs.wisc.edu:5432/postgres",
props);

Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select datname from
pg_database order by 1");
while (rs.next()) {
System.out.print("Database name returned: ");
System.out.println(rs.getString(1));
}
rs.close();
st.close();

} catch (Throwable ex) {
System.err.println("Uncaught exception in main...");
ex.printStackTrace();
}
}
}

Am I forgetting to set something up? I know that GSSAPI in JDBC is
unsupported currently but it would be really nice to offer it even in
a beta capacity. Thanks.

Peter

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Stephen Frost 2008-07-25 00:50:12 Re: GSSAPI/KRB5 and JDBC (again)
Previous Message Konrad Machlowski 2008-07-24 17:27:29 Passing arrays