tmpl

package
v0.2.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValidityWarnThreshold = "720h"
	TimeFormat            = "2006-01-02 15:04 MST"
	MinRsaKeyBitLength    = 2048
)
View Source
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

View Source
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"},
}
View Source
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",
}
View Source
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 BitLength added in v0.1.27

func BitLength(key *rsa.PublicKey) string

func BuildCertFuncMap

func BuildCertFuncMap() template.FuncMap

BuildCertFuncMap build a template.FuncMap with some extras.

func BuildDefaultCertTemplate

func BuildDefaultCertTemplate(cert *x509.Certificate, verbose bool) ([]byte, error)

func Colorize

func Colorize(text, c string) string

Colorize colorizes the given string.

func ColorizeTimeString

func ColorizeTimeString(t time.Time, c string) string

func CommonName

func CommonName(name pkix.Name) string

func ExtKeyUsage

func ExtKeyUsage(eku x509.ExtKeyUsage) string

ExtKeyUsage returns extended key usage string from a certificate.

func Hexadecimalize

func Hexadecimalize(data []byte) string

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 HighlightCA(isCA bool) string

func KeyUsage

func KeyUsage(ku x509.KeyUsage) []string

KeyUsage returns key usage string from a certificate.

func NotAfter

func NotAfter(end time.Time) string

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

func NotBefore(start time.Time) string

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 ShortName

func ShortName(name pkix.Name) (out 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

type AlgorithmDesc struct {
	Color *color.Color
	Name  string
}

func (*AlgorithmDesc) String

func (a *AlgorithmDesc) String() string

type OidDesc

type OidDesc struct {
	Name     string
	Short    string
	Slug     string
	Multiple bool
}

OidDesc returns a human-readable name, a short acronym from RFC1485, a snake_case slug suitable as a json key, and a boolean describing whether multiple copies can appear on an X509 cert.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL