mirror of
https://github.com/square/certigo.git
synced 2024-04-21 12:32:40 +00:00
Improve formatting, show if self-signed
This commit is contained in:
+2
-1
@@ -35,7 +35,7 @@ import (
|
||||
var layout = `Serial: {{.SerialNumber}}
|
||||
Not Before: {{.NotBefore | certStart}}
|
||||
Not After : {{.NotAfter | certEnd}}
|
||||
Signature : {{.SignatureAlgorithm | algorithm}}
|
||||
Signature : {{.SignatureAlgorithm | algorithm}} {{if . | isSelfSigned}}(self-signed){{end}}
|
||||
Subject Info: {{if .Subject.CommonName}}
|
||||
CommonName: {{.Subject.CommonName}}{{end}} {{if .Subject.Organization}}
|
||||
Organization: {{.Subject.Organization}} {{end}} {{if .Subject.OrganizationalUnit}}
|
||||
@@ -80,6 +80,7 @@ func displayCert(cert certWithAlias) {
|
||||
"keyUsage": keyUsage,
|
||||
"extKeyUsage": extKeyUsage,
|
||||
"certWarnings": certWarnings,
|
||||
"isSelfSigned": isSelfSigned,
|
||||
}
|
||||
t := template.New("Cert template").Funcs(funcMap)
|
||||
t, _ = t.Parse(layout)
|
||||
|
||||
@@ -69,6 +69,11 @@ func verifyChain(certs []*x509.Certificate, dnsName, caPath string) {
|
||||
} else {
|
||||
name = fmt.Sprintf("Serial #%s", cert.SerialNumber.String())
|
||||
}
|
||||
|
||||
if isSelfSigned(cert) {
|
||||
name += green.SprintfFunc()(" [self-signed]")
|
||||
}
|
||||
|
||||
for _, alg := range badSignatureAlgorithms {
|
||||
if cert.SignatureAlgorithm == alg {
|
||||
name += red.SprintfFunc()(" [%s]", alg.String())
|
||||
@@ -77,6 +82,10 @@ func verifyChain(certs []*x509.Certificate, dnsName, caPath string) {
|
||||
}
|
||||
names = append(names, name)
|
||||
}
|
||||
fmt.Printf("\t[%d] %s\n", i, strings.Join(names, "\n\t\t=> "))
|
||||
fmt.Printf("[%d] %s\n", i, strings.Join(names, "\n\t=> "))
|
||||
}
|
||||
}
|
||||
|
||||
func isSelfSigned(cert *x509.Certificate) bool {
|
||||
return cert.CheckSignatureFrom(cert) == nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user