This is an automated email from the ASF dual-hosted git repository.
rob pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 1c1fdd9 T3c cookie changes (#6601)
1c1fdd9 is described below
commit 1c1fdd92a72bb1bead550a024eb5389a404aec11
Author: Joe Pappano <[email protected]>
AuthorDate: Tue Mar 1 17:28:17 2022 -0500
T3c cookie changes (#6601)
* Added constant for time and date layout
* More descriptive error when certificate parsing occurs and date format
uses constant variable.
* added check for empty cookie which can occur when jason is valid but
doesn't match the struct
---
cache-config/t3c-apply/config/config.go | 1 +
cache-config/t3c-apply/torequest/cmd.go | 8 ++++----
cache-config/t3cutil/toreq/torequtil/torequtil.go | 5 +++++
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/cache-config/t3c-apply/config/config.go
b/cache-config/t3c-apply/config/config.go
index b4247fb..cdcf3e1 100644
--- a/cache-config/t3c-apply/config/config.go
+++ b/cache-config/t3c-apply/config/config.go
@@ -147,6 +147,7 @@ func StrToUseGitFlag(str string) UseGitFlag {
type WaitForParentsFlag string
const WaitForParentsDefault = WaitForParentsReval
+const TimeAndDateLayout = "Jan 2, 2006 15:04 MST"
const (
WaitForParentsTrue = "true"
diff --git a/cache-config/t3c-apply/torequest/cmd.go
b/cache-config/t3c-apply/torequest/cmd.go
index ec505cd..b37702c 100644
--- a/cache-config/t3c-apply/torequest/cmd.go
+++ b/cache-config/t3c-apply/torequest/cmd.go
@@ -337,18 +337,18 @@ func checkRefs(cfg config.Cfg, cfgFile []byte,
filesAdding []string) error {
return nil
}
-//checkCert checks the validity of the ssl certificate
+//checkCert checks the validity of the ssl certificate.
func checkCert(c []byte) error {
block, _ := pem.Decode(c)
cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
- return err
+ return errors.New("Error Parsing Certificate: " + err.Error())
}
if cert.NotAfter.Unix() < time.Now().Unix() {
- err = errors.New("Certificate expired: " +
cert.NotAfter.Format("Jan 2, 2006 15:04 MST"))
+ err = errors.New("Certificate expired: " +
cert.NotAfter.Format(config.TimeAndDateLayout))
log.Warnf(err.Error())
} else {
- log.Infof("Certificate valid until %s ",
cert.NotAfter.Format("Jan 2, 2006 15:04 MST"))
+ log.Infof("Certificate valid until %s ",
cert.NotAfter.Format(config.TimeAndDateLayout))
}
return err
}
diff --git a/cache-config/t3cutil/toreq/torequtil/torequtil.go
b/cache-config/t3cutil/toreq/torequtil/torequtil.go
index 7091fe9..9208df4 100644
--- a/cache-config/t3cutil/toreq/torequtil/torequtil.go
+++ b/cache-config/t3cutil/toreq/torequtil/torequtil.go
@@ -107,6 +107,11 @@ func GetFsCookie(cookiePath string) (FsCookie, error) {
if err != nil {
return FsCookie{Cookies: nil}, err
}
+ for _, c := range cookie.Cookies {
+ if len(c.Cookie.String()) == 0 {
+ return FsCookie{Cookies: nil}, errors.New("file system
cookie was empty")
+ }
+ }
return cookie, err
}