Skip to content

Commit fd4768a

Browse files
authored
Merge pull request #53 from abhijitWakchaure/master
support more generic TLS params
2 parents d998bcd + e4837e8 commit fd4768a

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

flow-state/store/postgres/connection.go

+6-10
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ func (*PgFactory) Type() string {
5151
}
5252

5353
func decodeTLSParam(tlsparm string) string {
54-
switch tlsparm {
55-
case "VerifyCA":
54+
switch strings.ToLower(tlsparm) {
55+
case "verifyca", "one-way":
5656
return "verify-ca"
57-
case "VerifyFull":
57+
case "verifyfull", "two-way":
5858
return "verify-full"
5959
default:
60-
return ""
60+
return tlsparm
6161
}
6262
}
6363

@@ -87,10 +87,6 @@ func NewDB(settings map[string]interface{}) (*sql.DB, error) {
8787
if cUser == "" {
8888
return nil, errors.New("Required Parameter User is missing")
8989
}
90-
cPassword := s.Password
91-
if cPassword == "" {
92-
return nil, errors.New("Required Parameter Password is missing")
93-
}
9490

9591
cMaxOpenConn := s.MaxOpenConnections
9692
if cMaxOpenConn == 0 {
@@ -143,12 +139,12 @@ func NewDB(settings map[string]interface{}) (*sql.DB, error) {
143139
var conninfo string
144140
if cTLSConfig == false {
145141
logCache.Debugf("Login attempting plain connection")
146-
conninfo = fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable connect_timeout=%d ", cHost, cPort, cUser, cPassword, cDbName, cConnTimeout)
142+
conninfo = fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable connect_timeout=%d ", cHost, cPort, cUser, s.Password, cDbName, cConnTimeout)
147143
} else {
148144
logCache.Debugf("Login attempting SSL connection")
149145
cTLSMode := s.TLSMode
150146
conninfo = fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s connect_timeout=%d ",
151-
cHost, cPort, cUser, cPassword, cDbName, decodeTLSParam(cTLSMode), cConnTimeout)
147+
cHost, cPort, cUser, s.Password, cDbName, decodeTLSParam(cTLSMode), cConnTimeout)
152148
//create temp file
153149
pwd, err := os.Getwd()
154150
if err != nil {

0 commit comments

Comments
 (0)