Skip to content

Commit

Permalink
feat: Allow for inlining client cert
Browse files Browse the repository at this point in the history
It is useful when you are using Google Cloud SQL and don't want to
be forced to use temporary files to load certificate
  • Loading branch information
vr committed Aug 31, 2023
1 parent fea83f3 commit 7af89bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions postgresql/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func (db *DBConnection) isSuperuser() (bool, error) {
type ClientCertificateConfig struct {
CertificatePath string
KeyPath string
SSLInline bool
}

// Config - provider config
Expand Down Expand Up @@ -215,6 +216,9 @@ func (c *Config) connParams() []string {
if c.SSLClientCert != nil {
params["sslcert"] = c.SSLClientCert.CertificatePath
params["sslkey"] = c.SSLClientCert.KeyPath
if c.SSLClientCert.SSLInline {
params["sslinline"] = strconv.FormatBool(c.SSLClientCert.SSLInline)
}
}

if c.SSLRootCertPath != "" {
Expand Down
6 changes: 6 additions & 0 deletions postgresql/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ func Provider() *schema.Provider {
Description: "The SSL client certificate private key file path. The file must contain PEM encoded data.",
Required: true,
},
"sslinline": {
Type: schema.TypeBool,
Description: "Must be set to true if you are inlining the cert/key instead of using a file path.",
Optional: true,
},
},
},
MaxItems: 1,
Expand Down Expand Up @@ -296,6 +301,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config.SSLClientCert = &ClientCertificateConfig{
CertificatePath: spec["cert"].(string),
KeyPath: spec["key"].(string),
SSLInline: spec["sslinline"].(bool),
}
}
}
Expand Down

0 comments on commit 7af89bd

Please sign in to comment.