x509util

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: BSD-3-Clause Imports: 16 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 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 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 VerifyValidity

func VerifyValidity(cert *x509.Certificate, days int) (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) (privateKeyInfo PrivateKeyInfo, err error)

ParsePrivateKeyFile parses a private key file in PEM format and returns a private key.

type PublicKeyInfo

type PublicKeyInfo struct {
	SourceName         string
	TypeLabel          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) (publicKeyInfo PublicKeyInfo, err error)

ExtractPublicKeyFromCertificate extracts a public key from a certificate.

func ExtractPublicKeyFromPrivateKey

func ExtractPublicKeyFromPrivateKey(privateKeyInfo PrivateKeyInfo) (publicKeyInfo 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