@@ -59,6 +59,9 @@ func ssl(o values) (func(net.Conn) (net.Conn, error), error) {
5959 return nil , err
6060 }
6161
62+ // This pseudo-parameter is not recognized by the PostgreSQL server, so let's delete it after use.
63+ delete (o , "sslinline" )
64+
6265 // Accept renegotiation requests initiated by the backend.
6366 //
6467 // 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) {
8386// in the user's home directory. The configured files must exist and have
8487// the correct permissions.
8588func 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+
86102 // user.Current() might fail when cross-compiling. We have to ignore the
87103 // error and continue without home directory defaults, since we wouldn't
88104 // know from where to load them.
@@ -137,9 +153,19 @@ func sslCertificateAuthority(tlsConf *tls.Config, o values) error {
137153 if sslrootcert := o ["sslrootcert" ]; len (sslrootcert ) > 0 {
138154 tlsConf .RootCAs = x509 .NewCertPool ()
139155
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+ }
143169 }
144170
145171 if ! tlsConf .RootCAs .AppendCertsFromPEM (cert ) {
0 commit comments