Commands: Show certificate chain Length

pull/4933/head
风扇滑翔翼 2025-07-25 08:48:03 +00:00 committed by GitHub
parent 4f45c5faa5
commit 3ec45b8b80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 5 deletions

View File

@ -122,13 +122,23 @@ func executePing(cmd *base.Command, args []string) {
}
func printCertificates(certs []*x509.Certificate) {
var leaf *x509.Certificate
var length int
for _, cert := range certs {
if len(cert.DNSNames) == 0 {
continue
length += len(cert.Raw)
if len(cert.DNSNames) != 0 {
leaf = cert
}
fmt.Println("Cert's signature algorithm: ", cert.SignatureAlgorithm.String())
fmt.Println("Cert's publicKey algorithm: ", cert.PublicKeyAlgorithm.String())
fmt.Println("Cert's allowed domains: ", cert.DNSNames)
}
if len(certs) > 1 {
fmt.Println("Certificate chain length: ", length)
} else {
fmt.Println("Certificate chain length: ", length, "(only one certificate found)")
}
if leaf != nil {
fmt.Println("Cert's signature algorithm: ", leaf.SignatureAlgorithm.String())
fmt.Println("Cert's publicKey algorithm: ", leaf.PublicKeyAlgorithm.String())
fmt.Println("Cert's allowed domains: ", leaf.DNSNames)
}
}