ca

package
v0.0.0-...-efb87f3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeCert

func DecodeCert(certPEM []byte) (*x509.Certificate, error)

DecodeCert will decode a PEM encoded certificate.

func DecodeKey

func DecodeKey(keyPEM []byte) (*ecdsa.PrivateKey, error)

DecodeKey will decode a PEM encoded private key.

func EncodeCert

func EncodeCert(cert *x509.Certificate) ([]byte, error)

EncodeCert is a small helper function that will PEM encode a certificate.

func EncodeKey

func EncodeKey(privateKey *ecdsa.PrivateKey) ([]byte, error)

EncodeKey is a helper that will PEM encode a private key.

func GenerateCSR

func GenerateCSR(key *ecdsa.PrivateKey, commonName string, ips []net.IP) (*x509.CertificateRequest, error)

GenerateCSR will generate a new certificate signing request.

func GenerateKey

func GenerateKey() (*ecdsa.PrivateKey, error)

GenerateKey will generate a new ECDSA private key.

func RandomString

func RandomString(length int) string

RandomString will generate a pseudo-random string consisting of length alphanumeric runes.

Types

type CA

type CA struct {
	Certificate *x509.Certificate
	// contains filtered or unexported fields
}

CA represents a certificate authority.

func InitCA

func InitCA() (*CA, error)

InitCA will start a new certificate authority.

func OpenCA

func OpenCA(keyPEM []byte, certPEM []byte) (*CA, error)

OpenCA will instantiate a new CA from an existing key/cert pair.

func (*CA) CertPool

func (ca *CA) CertPool() *x509.CertPool

CertPool returns a pool suitable for use in http clients.

func (*CA) CertificatePEM

func (ca *CA) CertificatePEM() ([]byte, error)

CertificatePEM will return the root certificate in PEM format.

func (*CA) Fingerprint256

func (ca *CA) Fingerprint256() string

Fingerprint256 returns the certificate sha256 fingerprint as a string.

func (*CA) KeyPEM

func (ca *CA) KeyPEM() ([]byte, error)

KeyPEM will return the private CA key PEM encoded.

func (*CA) SignCSR

func (ca *CA) SignCSR(csr *x509.CertificateRequest) (*x509.Certificate, error)

SignCSR will sign a CSR and generate a new certificate.

func (*CA) Verify

func (ca *CA) Verify(cert *x509.Certificate) (bool, error)

Verify that cert is signed by our root.

func (*CA) VerifyHTTPRequest

func (ca *CA) VerifyHTTPRequest(req *http.Request) (string, error)

VerifyHTTPRequest verifies that a HTTP remote has presented a certificate signed by this CA.

Jump to

Keyboard shortcuts

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