x509util

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
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

func DistinguishedName(dn pkix.Name, dnType DNType) string

DistinguishedName converts Distinguished Name to the specified type.

func Encode2DigitHex

func Encode2DigitHex(bytes []byte) string

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

func GetRootCertPool(rootCerts []*x509.Certificate, enableSSLCertDir bool) (*x509.CertPool, error)

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

func ReadPasswordFile(passwordFile string) ([]byte, error)

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 DNType

type DNType int

DNType is a type of a Distinguished Name.

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.

Jump to

Keyboard shortcuts

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