@@ -59,6 +59,9 @@ func ssl(o values) (func(net.Conn) (net.Conn, error), error) {
59
59
return nil , err
60
60
}
61
61
62
+ // This pseudo-parameter is not recognized by the PostgreSQL server, so let's delete it after use.
63
+ delete (o , "sslinline" )
64
+
62
65
// Accept renegotiation requests initiated by the backend.
63
66
//
64
67
// Renegotiation was deprecated then removed from PostgreSQL 9.5, but
@@ -83,6 +86,19 @@ func ssl(o values) (func(net.Conn) (net.Conn, error), error) {
83
86
// in the user's home directory. The configured files must exist and have
84
87
// the correct permissions.
85
88
func sslClientCertificates (tlsConf * tls.Config , o values ) error {
89
+ sslinline := o ["sslinline" ]
90
+ if sslinline == "true" {
91
+ cert , err := tls .X509KeyPair ([]byte (o ["sslcert" ]), []byte (o ["sslkey" ]))
92
+ // Clear out these params, in case they were to be sent to the PostgreSQL server by mistake
93
+ o ["sslcert" ] = ""
94
+ o ["sslkey" ] = ""
95
+ if err != nil {
96
+ return err
97
+ }
98
+ tlsConf .Certificates = []tls.Certificate {cert }
99
+ return nil
100
+ }
101
+
86
102
// user.Current() might fail when cross-compiling. We have to ignore the
87
103
// error and continue without home directory defaults, since we wouldn't
88
104
// know from where to load them.
@@ -137,9 +153,19 @@ func sslCertificateAuthority(tlsConf *tls.Config, o values) error {
137
153
if sslrootcert := o ["sslrootcert" ]; len (sslrootcert ) > 0 {
138
154
tlsConf .RootCAs = x509 .NewCertPool ()
139
155
140
- cert , err := ioutil .ReadFile (sslrootcert )
141
- if err != nil {
142
- return err
156
+ sslinline := o ["sslinline" ]
157
+
158
+ var cert []byte
159
+ if sslinline == "true" {
160
+ // // Clear out this param, in case it were to be sent to the PostgreSQL server by mistake
161
+ o ["sslrootcert" ] = ""
162
+ cert = []byte (sslrootcert )
163
+ } else {
164
+ var err error
165
+ cert , err = ioutil .ReadFile (sslrootcert )
166
+ if err != nil {
167
+ return err
168
+ }
143
169
}
144
170
145
171
if ! tlsConf .RootCAs .AppendCertsFromPEM (cert ) {
0 commit comments