mx509

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RootCACert
	IntermediateCACert
	OCSPSigningCert
	ServerCert
	ClientCert
)

Certificate types handled by this package

Variables

This section is empty.

Functions

func CreateCSR added in v0.2.8

func CreateCSR(certInfo *CertInfo, key crypto.PrivateKey) ([]byte, error)

CreateCSR creates a private key and certificate signing request, currently only for a client certificate. the CertInfo needs only the CertType to be Client, and the O/OU/CN filled in for the Subject Name.

func CreateCert

func CreateCert(certInfo *CertInfo, key crypto.PrivateKey, CAkey crypto.PrivateKey, CACert *x509.Certificate) (*x509.Certificate, []byte, error)

CreateCert creates a certificate from a private key and a CA, or a self-signed certificate a flag controls what kind of certificate is generated returns the certificate, and a byte slice PEM-formatted version

func CreateKeyFile

func CreateKeyFile() []byte

CreateKeyFile creates a random 32 bytes and returns it as a byte64 encoded string.

func CreatePrivateKey

func CreatePrivateKey(rsabits int, encrypt bool) (crypto.PrivateKey, []byte, string, error)

CreatePrivateKey returns a PKCS#8 formatted private key it is an RSA private key of the specified length. it is returned as a pointer to an rsa.PrivateKey, and also in PEM format as a byte slice. If encrypted, the random password is returned also.

func CreateSSHKeyPair added in v0.2.8

func CreateSSHKeyPair(rsabits int, encrypt bool) (pub ssh.PublicKey, pubBytes []byte, priv crypto.PrivateKey, privPEM []byte, err error)

func GetCSR added in v0.2.8

func GetCSR(pemCSR []byte) (*x509.CertificateRequest, error)

GetCSR gets the certificate from a PEM-format byte slice

func GetCertificate

func GetCertificate(pemCert []byte) (*x509.Certificate, error)

GetCertificate gets the certificate from a PEM-format byte slice

func GetPrivateKey

func GetPrivateKey(pemKey []byte) (crypto.PrivateKey, error)

GetPrivateKey gets the private kay from a PEM-format byte slice

Types

type CertInfo

type CertInfo struct {
	CertType  int // certificate type
	ValidDays int // how many days it should remain valid
	O         string
	OU        string
	CN        string
	Hosts     []string
}

Jump to

Keyboard shortcuts

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