Skip to content

Commit

Permalink
fix: interpretation of empty but set "ssl" connection property
Browse files Browse the repository at this point in the history
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 91f05b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Expand Up @@ -61,7 +61,8 @@ public ProtocolConnection openConnectionImpl(HostSpec[] hostSpecs, String user,
boolean trySSL; boolean trySSL;
String sslmode = PGProperty.SSL_MODE.get(info); String sslmode = PGProperty.SSL_MODE.get(info);
if (sslmode == null) { // Fall back to the ssl property 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 { } else {
if ("disable".equals(sslmode)) { if ("disable".equals(sslmode)) {
requireSSL = trySSL = false; requireSSL = trySSL = false;
Expand Down
Expand Up @@ -76,7 +76,8 @@ public ProtocolConnection openConnectionImpl(HostSpec[] hostSpecs, String user,
boolean trySSL; boolean trySSL;
String sslmode = PGProperty.SSL_MODE.get(info); String sslmode = PGProperty.SSL_MODE.get(info);
if (sslmode == null) { // Fall back to the ssl property 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 { } else {
if ("disable".equals(sslmode)) { if ("disable".equals(sslmode)) {
requireSSL = trySSL = false; requireSSL = trySSL = false;
Expand Down
Expand Up @@ -453,7 +453,7 @@ public void setSsl(boolean enabled) {
if (enabled) { if (enabled) {
PGProperty.SSL.set(properties, true); PGProperty.SSL.set(properties, true);
} else { } else {
PGProperty.SSL.set(properties, null); PGProperty.SSL.set(properties, false);
} }
} }


Expand All @@ -462,7 +462,8 @@ public void setSsl(boolean enabled) {
* @see PGProperty#SSL * @see PGProperty#SSL
*/ */
public boolean getSsl() { 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));
} }


/** /**
Expand Down

0 comments on commit 91f05b4

Please sign in to comment.