Skip to content

Commit c659a21

Browse files
committed
MTV-2146 | Ignore TLS Cert msg when skipCertVerify
'TLS certificate cannot be retrieved' message should be ignored when skipVerify flag is set to true. When user specified they want to skip ceritificate verification we want to just inform the customer about failed connection and not about certificate. The reason behind this is that the GetTlsCertificate is our first attempt to connect to the provider and when connection fails, the customer will still get the certificate error even when they don't care about certificates. Signed-off-by: Stefan Olenocin <solenoci@redhat.com>
1 parent 2385533 commit c659a21

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

pkg/controller/provider/validation.go

+23-8
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,29 @@ func (r *Reconciler) validateSecret(provider *api.Provider) (secret *core.Secret
238238
if crt, err := util.GetTlsCertificate(url, secret); err == nil {
239239
provider.Status.Fingerprint = util.Fingerprint(crt)
240240
} else {
241-
log.Error(err, "failed to get TLS certificate", "url", provider.Spec.URL)
242-
provider.Status.SetCondition(libcnd.Condition{
243-
Type: ConnectionTestFailed,
244-
Status: True,
245-
Reason: Tested,
246-
Category: Critical,
247-
Message: "TLS certificate cannot be retrieved",
248-
})
241+
// When user specified they want to skip ceritificate verification we want to just
242+
// inform the customer about failed connection and not about certificate.
243+
// The reason behind this is that the GetTlsCertificate is our first attempt to connect
244+
// to the provider and when connection fails, the customer will still get the cert
245+
// error even when they don't care about certificates.
246+
if vsphere.GetInsecureSkipVerifyFlag(secret) {
247+
log.Error(err, "failed to connect to provider", "url", provider.Spec.URL)
248+
provider.Status.SetCondition(libcnd.Condition{
249+
Type: ConnectionTestFailed,
250+
Status: True,
251+
Reason: Tested,
252+
Category: Critical,
253+
})
254+
} else {
255+
log.Error(err, "failed to get TLS certificate", "url", provider.Spec.URL)
256+
provider.Status.SetCondition(libcnd.Condition{
257+
Type: ConnectionTestFailed,
258+
Status: True,
259+
Reason: Tested,
260+
Category: Critical,
261+
Message: "TLS certificate cannot be retrieved",
262+
})
263+
}
249264
}
250265
case api.OVirt:
251266
keyList = []string{

0 commit comments

Comments
 (0)