Skip to content

Commit

Permalink
Merge pull request #53 from abhijitWakchaure/master
Browse files Browse the repository at this point in the history
support more generic TLS params
  • Loading branch information
abhide-tibco authored Dec 15, 2022
2 parents d998bcd + e4837e8 commit fd4768a
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions flow-state/store/postgres/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ func (*PgFactory) Type() string {
}

func decodeTLSParam(tlsparm string) string {
switch tlsparm {
case "VerifyCA":
switch strings.ToLower(tlsparm) {
case "verifyca", "one-way":
return "verify-ca"
case "VerifyFull":
case "verifyfull", "two-way":
return "verify-full"
default:
return ""
return tlsparm
}
}

Expand Down Expand Up @@ -87,10 +87,6 @@ func NewDB(settings map[string]interface{}) (*sql.DB, error) {
if cUser == "" {
return nil, errors.New("Required Parameter User is missing")
}
cPassword := s.Password
if cPassword == "" {
return nil, errors.New("Required Parameter Password is missing")
}

cMaxOpenConn := s.MaxOpenConnections
if cMaxOpenConn == 0 {
Expand Down Expand Up @@ -143,12 +139,12 @@ func NewDB(settings map[string]interface{}) (*sql.DB, error) {
var conninfo string
if cTLSConfig == false {
logCache.Debugf("Login attempting plain connection")
conninfo = fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable connect_timeout=%d ", cHost, cPort, cUser, cPassword, cDbName, cConnTimeout)
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)
} else {
logCache.Debugf("Login attempting SSL connection")
cTLSMode := s.TLSMode
conninfo = fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s connect_timeout=%d ",
cHost, cPort, cUser, cPassword, cDbName, decodeTLSParam(cTLSMode), cConnTimeout)
cHost, cPort, cUser, s.Password, cDbName, decodeTLSParam(cTLSMode), cConnTimeout)
//create temp file
pwd, err := os.Getwd()
if err != nil {
Expand Down

0 comments on commit fd4768a

Please sign in to comment.