Documentation ¶
Index ¶
- Constants
- Variables
- func BitLength(key *rsa.PublicKey) string
- func BuildCertFuncMap() template.FuncMap
- func BuildDefaultCertTemplate(cert *x509.Certificate, verbose bool) ([]byte, error)
- func Colorize(text, c string) string
- func ColorizeTimeString(t time.Time, c string) string
- func CommonName(name pkix.Name) string
- func ExtKeyUsage(eku x509.ExtKeyUsage) string
- func Hexadecimalize(data []byte) string
- func HighlightAlgorithm(alg x509.SignatureAlgorithm) string
- func HighlightCA(isCA bool) string
- func KeyUsage(ku x509.KeyUsage) []string
- func NotAfter(end time.Time) string
- func NotBefore(start time.Time) string
- func OidName(oid asn1.ObjectIdentifier) string
- func OidShort(oid asn1.ObjectIdentifier) string
- func ShortName(name pkix.Name) (out string)
- func ShowBitLength(cert *x509.Certificate) bool
- func ShowNameConstraints(cert *x509.Certificate) bool
- func ShowSelfSigned(cert *x509.Certificate) string
- type AlgorithmDesc
- type OidDesc
Constants ¶
const ( ValidityWarnThreshold = "720h" TimeFormat = "2006-01-02 15:04 MST" MinRsaKeyBitLength = 2048 )
const ( VerboseTmpl = `` /* 2407-byte string literal not displayed */ SimpleTmpl = `` /* 396-byte string literal not displayed */ WarningTmpl = ` {{- if .Warnings}} Warnings: {{- range .Warnings}} {{colorize . "red"}} {{- end}} {{- end}}` )
Variables ¶
var ( Green = color.New(color.Bold, color.FgGreen) Yellow = color.New(color.Bold, color.FgYellow) Red = color.New(color.Bold, color.FgRed) Blue = color.New(color.Bold, color.FgBlue) Cyan = color.New(color.Bold, color.FgCyan) )
var AlgorithmMapping = map[x509.SignatureAlgorithm]AlgorithmDesc{ x509.MD2WithRSA: {Red, "MD2-RSA"}, x509.MD5WithRSA: {Red, "MD5-RSA"}, x509.SHA1WithRSA: {Red, "SHA1-RSA"}, x509.SHA256WithRSA: {Green, "SHA256-RSA"}, x509.SHA384WithRSA: {Green, "SHA384-RSA"}, x509.SHA512WithRSA: {Green, "SHA512-RSA"}, x509.DSAWithSHA1: {Red, "DSA-SHA1"}, x509.DSAWithSHA256: {Red, "DSA-SHA256"}, x509.ECDSAWithSHA1: {Red, "ECDSA-SHA1"}, x509.ECDSAWithSHA256: {Green, "ECDSA-SHA256"}, x509.ECDSAWithSHA384: {Green, "ECDSA-SHA384"}, x509.ECDSAWithSHA512: {Green, "ECDSA-SHA512"}, x509.PureEd25519: {Green, "ED25519"}, }
var ExtKeyUsageStringMapping = map[x509.ExtKeyUsage]string{ x509.ExtKeyUsageAny: "Any", x509.ExtKeyUsageServerAuth: "TLS Web Server Authentication", x509.ExtKeyUsageClientAuth: "TLS Web Client Authentication", x509.ExtKeyUsageCodeSigning: "Code Signing", x509.ExtKeyUsageEmailProtection: "Email Protection", x509.ExtKeyUsageIPSECEndSystem: "IPSEC End System", x509.ExtKeyUsageIPSECTunnel: "IPSEC Tunnel", x509.ExtKeyUsageIPSECUser: "IPSEC User", x509.ExtKeyUsageTimeStamping: "Time Stamping", x509.ExtKeyUsageOCSPSigning: "OCSP Signing", x509.ExtKeyUsageMicrosoftServerGatedCrypto: "Microsoft ServerGatedCrypto", x509.ExtKeyUsageNetscapeServerGatedCrypto: "Netscape ServerGatedCrypto", x509.ExtKeyUsageMicrosoftCommercialCodeSigning: "Microsoft CommercialCodeSigning", x509.ExtKeyUsageMicrosoftKernelCodeSigning: "Microsoft KernelCodeSigning", }
var KeyUsageStringMapping = map[x509.KeyUsage]string{ x509.KeyUsageDigitalSignature: "Digital Signature", x509.KeyUsageContentCommitment: "Content Commitment", x509.KeyUsageKeyEncipherment: "Key Encipherment", x509.KeyUsageDataEncipherment: "Data Encipherment", x509.KeyUsageKeyAgreement: "Key Agreement", x509.KeyUsageCertSign: "Certificate Sign", x509.KeyUsageCRLSign: "CRL Sign", x509.KeyUsageEncipherOnly: "Encipher Only", x509.KeyUsageDecipherOnly: "Decipher Only", }
Functions ¶
func BuildCertFuncMap ¶
BuildCertFuncMap build a template.FuncMap with some extras.
func BuildDefaultCertTemplate ¶
func BuildDefaultCertTemplate(cert *x509.Certificate, verbose bool) ([]byte, error)
func CommonName ¶
func ExtKeyUsage ¶
func ExtKeyUsage(eku x509.ExtKeyUsage) string
ExtKeyUsage returns extended key usage string from a certificate.
func Hexadecimalize ¶
Hexadecimalize returns a colon separated, hexadecimal representation of a given byte array.
func HighlightAlgorithm ¶
func HighlightAlgorithm(alg x509.SignatureAlgorithm) string
HighlightAlgorithm changes the color of the signing algorithm.
func HighlightCA ¶ added in v0.2.3
func NotAfter ¶
NotAfter takes a given NotAfter time of a certificate and returns that colorized time properly based on how close it is to expiry. If the certificate is valid for more than one month returns a green string. If the certificate is valid is less than one month the string will be yellow. If the certificate has already expired, the string will be red.
func NotBefore ¶
NotBefore takes a given NotBefore time of a certificate and returns that colorized time properly based on how
func OidName ¶
func OidName(oid asn1.ObjectIdentifier) string
func OidShort ¶
func OidShort(oid asn1.ObjectIdentifier) string
func ShowBitLength ¶ added in v0.1.27
func ShowBitLength(cert *x509.Certificate) bool
func ShowNameConstraints ¶
func ShowNameConstraints(cert *x509.Certificate) bool
func ShowSelfSigned ¶
func ShowSelfSigned(cert *x509.Certificate) string
Types ¶
type AlgorithmDesc ¶
func (*AlgorithmDesc) String ¶
func (a *AlgorithmDesc) String() string