mirror of https://github.com/XTLS/Xray-core
Commands: Show certificate chain Length
parent
4f45c5faa5
commit
3ec45b8b80
|
@ -122,13 +122,23 @@ func executePing(cmd *base.Command, args []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func printCertificates(certs []*x509.Certificate) {
|
func printCertificates(certs []*x509.Certificate) {
|
||||||
|
var leaf *x509.Certificate
|
||||||
|
var length int
|
||||||
for _, cert := range certs {
|
for _, cert := range certs {
|
||||||
if len(cert.DNSNames) == 0 {
|
length += len(cert.Raw)
|
||||||
continue
|
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())
|
if len(certs) > 1 {
|
||||||
fmt.Println("Cert's allowed domains: ", cert.DNSNames)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue