Fall back to sslmode=disable if ssl mode is not set or invalid in bookmarks

This commit is contained in:
Dan Sosedoff
2017-06-05 21:29:09 -05:00
parent 943963f760
commit 75dc1c1548
3 changed files with 28 additions and 3 deletions

View File

@@ -54,6 +54,23 @@ func readServerConfig(path string) (Bookmark, error) {
bookmark.Port = 5432
}
// List of all supported by portgres modes
modes := []string{"disable", "allow", "prefer", "required", "verify-ca", "verify-full"}
valid := false
for _, mode := range modes {
if bookmark.Ssl == mode {
valid = true
break
}
}
// Fall back to a default mode if mode is not set or invalid
// Typical typo: ssl mode set to "disabled"
if bookmark.Ssl == "" || !valid {
bookmark.Ssl = "disable"
}
return bookmark, err
}