rob05c commented on a change in pull request #6522:
URL: https://github.com/apache/trafficcontrol/pull/6522#discussion_r809491124
##########
File path: cache-config/t3c-generate/cfgfile/sslkeys.go
##########
@@ -59,24 +61,39 @@ func GetSSLCertsAndKeyFiles(toData *t3cutil.ConfigData)
([]t3cutil.ATSConfigFile
key = append(key, '\n') // it's going to be a file,
needs a trailing newline to be POSIX-compliant.
}
+ var keyPairErr []string
+ pairErr := CheckKeyPair(key, cert, string(dsName))
+ if pairErr != nil {
+ keyPairErr = append(keyPairErr, pairErr.Error())
+ }
+
certName, keyName :=
atscfg.GetSSLMultiCertDotConfigCertAndKeyName(dsName, ds)
keyFile := t3cutil.ATSConfigFile{}
keyFile.Name = keyName
keyFile.Path = "/opt/trafficserver/etc/trafficserver/ssl/" //
TODO read config, don't hard code
keyFile.Text = string(key)
keyFile.Secure = true
- keyFile.Warnings = dsWarns
+ keyFile.Warnings = keyPairErr
configs = append(configs, keyFile)
certFile := t3cutil.ATSConfigFile{}
certFile.Name = certName
certFile.Path = "/opt/trafficserver/etc/trafficserver/ssl/" //
TODO read config, don't hard code
certFile.Text = string(cert)
certFile.Secure = true
- certFile.Warnings = dsWarns
+ certFile.Warnings = keyPairErr
configs = append(configs, certFile)
}
return configs, nil
}
+
+func CheckKeyPair(keyPem []byte, certPem []byte, ds string) error {
+ _, err := tls.X509KeyPair(certPem, keyPem)
+ if err != nil {
+ log.Warnf("Issue with keypair for %s: %s", ds, err)
Review comment:
It's uncommon to both log and return an error/warning. Doesn't this
cause it to print twice? Should this log be removed?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]