Permalink
Browse files

fix: interpretation of empty but set "ssl" connection property

Commit a6a61be ignored the case that
the "ssl" property is set but empty, which means "true" according to
the documentation.
The consequence is that no SSL connection is attempted in this case.

closes #528, closes #529
  • Loading branch information...
Laurenz Albe authored and vlsi committed Mar 7, 2016
1 parent 8bee06b commit 91f05b402bb1e19d507f365be890cee8a54dc00f
@@ -61,7 +61,8 @@ public ProtocolConnection openConnectionImpl(HostSpec[] hostSpecs, String user,
boolean trySSL;
String sslmode = PGProperty.SSL_MODE.get(info);
if (sslmode == null) { // Fall back to the ssl property
requireSSL = trySSL = PGProperty.SSL.getBoolean(info);
// assume "true" if the property is set but empty
requireSSL = trySSL = PGProperty.SSL.getBoolean(info) || "".equals(PGProperty.SSL.get(info));
} else {
if ("disable".equals(sslmode)) {
requireSSL = trySSL = false;
@@ -76,7 +76,8 @@ public ProtocolConnection openConnectionImpl(HostSpec[] hostSpecs, String user,
boolean trySSL;
String sslmode = PGProperty.SSL_MODE.get(info);
if (sslmode == null) { // Fall back to the ssl property
requireSSL = trySSL = PGProperty.SSL.getBoolean(info);
// assume "true" if the property is set but empty
requireSSL = trySSL = PGProperty.SSL.getBoolean(info) || "".equals(PGProperty.SSL.get(info));
} else {
if ("disable".equals(sslmode)) {
requireSSL = trySSL = false;
@@ -453,7 +453,7 @@ public void setSsl(boolean enabled) {
if (enabled) {
PGProperty.SSL.set(properties, true);
} else {
PGProperty.SSL.set(properties, null);
PGProperty.SSL.set(properties, false);
}
}
@@ -462,7 +462,8 @@ public void setSsl(boolean enabled) {
* @see PGProperty#SSL
*/
public boolean getSsl() {
return PGProperty.SSL.isPresent(properties);
// "true" if "ssl" is set but empty
return PGProperty.SSL.getBoolean(properties) || "".equals(PGProperty.SSL.get(properties));
}
/**

0 comments on commit 91f05b4

Please sign in to comment.