Fixes a logical isssue where I was checking an errors value, but the error may have been nil and therefore had no value

This commit is contained in:
sloumdrone 2019-09-28 16:58:42 -07:00
parent 2fd2d6c722
commit 8edf886488
1 changed files with 5 additions and 4 deletions

View File

@ -161,13 +161,14 @@ func Retrieve(host, port, resource string, td *TofuDigest) (string, error) {
}
if td.Exists(host) {
// See if we have a matching cert
err := td.Match(host, &connState)
if err != nil && err.Error() != "EXP" {
// On any error other than EXP (expired), return the error
// If there is no match and it isnt because of an expiration
// just return the error
return "", err
} else if err.Error() == "EXP" {
// If the certificate we had was expired, check if they have
// offered a new valid cert and update the certificate
} else if err != nil {
// The cert expired, see if they are offering one that is valid...
err := td.newCert(host, &connState)
if err != nil {
// If there are no valid certs to offer, let the client know