Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: we will ask the server if it supports GSS Encryption if gssEncryption is prefer or require #2396

Merged
merged 2 commits into from Jan 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -31,7 +31,6 @@
import org.postgresql.sspi.ISSPIClient;
import org.postgresql.util.GT;
import org.postgresql.util.HostSpec;
import org.postgresql.util.KerberosTicket;
import org.postgresql.util.MD5Digest;
import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
Expand Down Expand Up @@ -442,15 +441,16 @@ private PGStream enableGSSEncrypted(PGStream pgStream, GSSEncMode gssEncMode, St
return pgStream;
}

// If there is not credential cache there is little point in attempting this
if (!KerberosTicket.credentialCacheExists(info)) {
if ( gssEncMode == GSSEncMode.REQUIRE ) {
throw new PSQLException("GSSAPI encryption required but was impossible (possibly no credential cache)", PSQLState.CONNECTION_REJECTED);
} else {
return pgStream;
}
}

/*
at this point gssEncMode is either PREFER or REQUIRE
libpq looks to see if there is a ticket in the cache before asking
the server if it supports encrypted GSS connections or not.
since the user has specifically asked or either prefer or require we can
assume they want it.
*/
/*
let's see if the server will allow a GSS encrypted connection
*/
String user = PGProperty.USER.get(info);
if (user == null) {
throw new PSQLException("GSSAPI encryption required but was impossible user is null", PSQLState.CONNECTION_REJECTED);
Expand Down