Merge branch 'improved-cert-error-messaging' of sloum/bombadillo into develop

This commit is contained in:
Sloom Sloum Sluom IV 2019-10-12 14:49:40 -04:00 committed by Gitea
commit 9e8e7ee5b1
3 changed files with 19 additions and 5 deletions

View File

@ -289,8 +289,15 @@ func (c *client) simpleCommand(action string) {
case "B", "BOOKMARKS":
c.BookMarks.ToggleOpen()
c.Draw()
case "R", "REFRESH":
// TODO build refresh code
case "R", "RELOAD":
c.ClearMessage()
err := c.ReloadPage()
if err != nil {
c.SetMessage(err.Error(), false)
c.DrawMessage()
} else {
c.Draw()
}
case "SEARCH":
c.search("", "", "?")
case "HELP", "?":

View File

@ -69,7 +69,7 @@ func (s *scanner) scanText() Token {
capInput := strings.ToUpper(buf.String())
switch capInput {
case "D", "DELETE", "A", "ADD","W", "WRITE",
"S", "SET", "R", "REFRESH", "SEARCH",
"S", "SET", "R", "RELOAD", "SEARCH",
"Q", "QUIT", "B", "BOOKMARKS", "H",
"HOME", "?", "HELP", "C", "CHECK",
"P", "PURGE":

View File

@ -100,17 +100,24 @@ func (t *TofuDigest) Match(host string, cState *tls.ConnectionState) error {
func (t *TofuDigest) newCert(host string, cState *tls.ConnectionState) error {
host = strings.ToLower(host)
now := time.Now()
var reasons strings.Builder
for _, cert := range cState.PeerCertificates {
for index, cert := range cState.PeerCertificates {
if index > 0 {
reasons.WriteString("; ")
}
if now.Before(cert.NotBefore) {
reasons.WriteString(fmt.Sprintf("Cert [%d] is not valid yet", index + 1))
continue
}
if now.After(cert.NotAfter) {
reasons.WriteString(fmt.Sprintf("Cert [%d] is expired", index + 1))
continue
}
if err := cert.VerifyHostname(host); err != nil {
reasons.WriteString(fmt.Sprintf("Cert [%d] hostname does not match", index + 1))
continue
}
@ -118,7 +125,7 @@ func (t *TofuDigest) newCert(host string, cState *tls.ConnectionState) error {
return nil
}
return fmt.Errorf("No valid certificates were offered by host %q", host)
return fmt.Errorf(reasons.String())
}
func (t *TofuDigest) IniDump() string {