Documentation
¶
Index ¶
- Constants
- func BuildCertificateChains(certs []*x509.Certificate, rootCertPool *x509.CertPool, currentTime time.Time) (chains [][]*x509.Certificate)
- func DistinguishedName(dn pkix.Name, dnType DNType) string
- func Encode2DigitHex(bytes []byte) string
- func GetIntermediateCertPool(intermediateCerts []*x509.Certificate) *x509.CertPool
- func GetRootCertPool(rootCerts []*x509.Certificate, enableSSLCertDir bool) (*x509.CertPool, error)
- func ParseCertificateFile(certFile string) (cert *x509.Certificate, err error)
- func ParseCertificateFiles(certFiles ...string) (certs []*x509.Certificate, err error)
- func ReadPasswordFile(passwordFile string) ([]byte, error)
- func VerifyCertificate(cert *x509.Certificate, parent *x509.Certificate, currentTime time.Time, ...) error
- func VerifyValidity(cert *x509.Certificate, days int, currentTime time.Time) (message string, err error)
- type DNType
- type PrivateKeyInfo
- type PublicKeyInfo
Constants ¶
const ( // strict format (RFC 4514) StrictDN = DNType(iota) // loose format with space LooseDN // OpenSSL format OpenSSLDN )
DNType name
Variables ¶
This section is empty.
Functions ¶
func BuildCertificateChains ¶ added in v0.7.0
func BuildCertificateChains(certs []*x509.Certificate, rootCertPool *x509.CertPool, currentTime time.Time) (chains [][]*x509.Certificate)
BuildCertificateChains builds certificate chains.
func DistinguishedName ¶
DistinguishedName converts Distinguished Name to the specified type.
func Encode2DigitHex ¶
Encode2DigitHex encodes bytes into two-digit hexadecimal strings separated by a colon.
func GetIntermediateCertPool ¶ added in v0.6.0
func GetIntermediateCertPool(intermediateCerts []*x509.Certificate) *x509.CertPool
GetIntermediateCertPool retrieves an intermediate certificate pool.
func GetRootCertPool ¶ added in v0.6.0
GetRootCertPool retrieves the root certificate pool. If root certificates are provided, return a certificate pool for them. If root certificates are not provided, return the system certificate pool.
func ParseCertificateFile ¶
func ParseCertificateFile(certFile string) (cert *x509.Certificate, err error)
ParseCertificateFile parses a certifcate file in PEM format and returns the first certificate.
func ParseCertificateFiles ¶
func ParseCertificateFiles(certFiles ...string) (certs []*x509.Certificate, err error)
ParseCertificateFiles parses certifcate files in PEM format and returns certificates.
func ReadPasswordFile ¶ added in v0.3.2
ReadPasswordFile reads the password from the password file.
func VerifyCertificate ¶ added in v0.8.0
func VerifyCertificate(cert *x509.Certificate, parent *x509.Certificate, currentTime time.Time, forceParentToCheck bool) error
VerifyCertificate verifies a certificate using the parent certificate.
func VerifyValidity ¶
func VerifyValidity(cert *x509.Certificate, days int, currentTime time.Time) (message string, err error)
VerifyValidity verifies the validity of the certificate.
Types ¶
type PrivateKeyInfo ¶
type PrivateKeyInfo struct { PublicKeyAlgorithm x509.PublicKeyAlgorithm Key interface{} }
PrivateKeyInfo describes the information of a private key.
func ParsePrivateKeyFile ¶
func ParsePrivateKeyFile(keyFile string, password []byte) (privKeyInfo PrivateKeyInfo, err error)
ParsePrivateKeyFile parses a private key file in PEM format and returns a private key.
type PublicKeyInfo ¶
type PublicKeyInfo struct { SourceName string Type string PublicKeyAlgorithm x509.PublicKeyAlgorithm Key interface{} KeyString string Option map[string]string }
PublicKeyInfo describes the information of a public key.
func ExtractPublicKeyFromCertificate ¶
func ExtractPublicKeyFromCertificate(cert *x509.Certificate) (pubKeyInfo PublicKeyInfo, err error)
ExtractPublicKeyFromCertificate extracts a public key from a certificate.
func ExtractPublicKeyFromPrivateKey ¶
func ExtractPublicKeyFromPrivateKey(privKeyInfo PrivateKeyInfo) (pubKeyInfo PublicKeyInfo, err error)
ExtractPublicKeyFromPrivateKey extracts a public key from a private key.