Source File
ssl.go
Belonging Package
github.com/lib/pq
package pq
import (
)
.InsecureSkipVerify = true
= true
case "verify-full":
.ServerName = ["host"]
case "disable":
return nil, nil
default:
return nil, fmterrorf(`unsupported sslmode %q; only "require" (default), "verify-full", "verify-ca", and "disable" supported`, )
}
:= sslClientCertificates(&, )
if != nil {
return nil,
}
= sslCertificateAuthority(&, )
if != nil {
return nil,
}
.Renegotiation = tls.RenegotiateFreelyAsClient
return func( net.Conn) (net.Conn, error) {
:= tls.Client(, &)
if {
:= sslVerifyCertificateAuthority(, &)
if != nil {
return nil,
}
}
return , nil
}, nil
}
:= ["sslkey"]
if len() == 0 && != nil {
= filepath.Join(.HomeDir, ".postgresql", "postgresql.key")
}
if len() > 0 {
if := sslKeyPermissions(); != nil {
return
}
}
, := tls.LoadX509KeyPair(, )
if != nil {
return
}
.Certificates = []tls.Certificate{}
return nil
}
func ( *tls.Conn, *tls.Config) error {
:= .Handshake()
if != nil {
return
}
:= .ConnectionState().PeerCertificates
:= x509.VerifyOptions{
DNSName: .ConnectionState().ServerName,
Intermediates: x509.NewCertPool(),
Roots: .RootCAs,
}
for , := range {
if == 0 {
continue
}
.Intermediates.AddCert()
}
_, = [0].Verify()
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |