Compare commits

...

10 Commits

Author SHA1 Message Date
Ashwathi Shiva
18299540e7 added comment 2020-06-25 16:19:04 -04:00
Ashwathi Shiva
20a57e9e2f Merge branch 'master' into preflight_openssl_verify
# Conflicts:
#	pkg/preflight/verify_ca.go
2020-06-25 16:16:41 -04:00
Ashwathi Shiva
117c3f7380 verify only server cert, not intermediate certs at this point 2020-06-25 16:13:39 -04:00
Ashwathi Shiva
b0ce7b2ed3 doc updates and minor additions 2020-06-24 10:00:18 -04:00
Ashwathi Shiva
7557315483 minor change 2020-06-24 00:13:08 -04:00
Ashwathi Shiva
f2a39dd637 preflight openssl verify included into all preflight checks 2020-06-24 00:03:22 -04:00
Ashwathi Shiva
06c154c630 Merge branch 'master' into preflight_openssl_verify 2020-06-23 23:56:13 -04:00
Ashwathi Shiva
45a2ac07a2 Openssl verify mongodbUrl and DiscoverUrl working 2020-06-23 23:55:04 -04:00
Ashwathi Shiva
ba4c64cf2b retrieve mongourl from CR 2020-06-18 09:05:17 -04:00
Ashwathi Shiva
30e3e189b5 initial commit: qliksense preflight verify-ca-chain 2020-06-18 00:00:53 -04:00

View File

@@ -93,25 +93,30 @@ func (qp *QliksensePreflight) extractCertAndVerify(server string, caCertificates
// Get the ConnectionState struct as that's the one which gives us x509.Certificate struct
x509Certificates := conn.ConnectionState().PeerCertificates
var serverCert *x509.Certificate
if len(x509Certificates) == 0 {
return fmt.Errorf("no server certificates retrieved from the server")
}
if len(x509Certificates) > 1 {
return fmt.Errorf("more than 1 server certificate retrieved from the server")
// we retrieve and verify the server certificate, we ignore intermediate certificates at this point.
for _, x509Cert := range x509Certificates {
if !x509Cert.IsCA {
serverCert = x509Cert
break
}
}
if serverCert == nil {
return fmt.Errorf("no valid server certificates retrieved from the server")
}
// execute verify cmd
roots := x509.NewCertPool()
ok := roots.AppendCertsFromPEM([]byte(caCertificates))
if !ok {
if ok := roots.AppendCertsFromPEM([]byte(caCertificates)); !ok {
return fmt.Errorf("failed to parse root certificate.")
}
opts := x509.VerifyOptions{
Roots: roots,
DNSName: u.Hostname(),
Intermediates: x509.NewCertPool(),
Roots: roots,
DNSName: u.Hostname(),
}
if _, err := x509Certificates[0].Verify(opts); err != nil {
if _, err := serverCert.Verify(opts); err != nil {
return fmt.Errorf("failed to verify certificate: " + err.Error())
}
return nil