ca

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 18 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownPrivateKey = errors.New("unknown private key")
	ErrUnknownAlgorithm  = errors.New("unknown algorithm")
)
View Source
var (
	ErrInvalidCertOptions = errors.New("invalid certificate options")
)

Functions

func CreateGeneralCertificate added in v1.1.0

func CreateGeneralCertificate(keyPair KeyPair, certOpts ...CertificateOption) (*x509.Certificate, error)

CreateGeneralCertificate create a general certificate signed by parent private key

func CreateMiddleRootCertificate added in v1.1.0

func CreateMiddleRootCertificate(keyPair KeyPair, certOpts ...CertificateOption) (*x509.Certificate, error)

CreateMiddleRootCertificate using parent certificate and parent private key to create a middle root certificate

func CreateSelfSignedRootCertificate added in v1.1.0

func CreateSelfSignedRootCertificate(keyPair KeyPair, certOpts ...CertificateOption) (*x509.Certificate, error)

CreateSelfSignedRootCertificate create a self-signed root certificate

func EncodeCertificateChain

func EncodeCertificateChain(out io.Writer, certificates []*x509.Certificate) (err error)

func EncodePKCS1PrivateKey

func EncodePKCS1PrivateKey(out io.Writer, privateKey any) (err error)

func EncodePKCS8PrivateKey

func EncodePKCS8PrivateKey(out io.Writer, privateKey any) (err error)

Types

type CertificateOption added in v1.1.0

type CertificateOption interface {
	// contains filtered or unexported methods
}

func WithCA added in v1.1.0

func WithCA(isCA bool) CertificateOption

func WithDomains added in v1.1.0

func WithDomains(domains []string) CertificateOption

func WithIPs added in v1.1.0

func WithIPs(ips []string) CertificateOption

func WithIssuer added in v1.1.0

func WithIssuer(issuer *x509.Certificate) CertificateOption

func WithIssuerPrivateKey added in v1.1.0

func WithIssuerPrivateKey(issuerPrivateKey any) CertificateOption

func WithNotAfter added in v1.1.0

func WithNotAfter(notAfter time.Time) CertificateOption

func WithNotBefore added in v1.1.0

func WithNotBefore(notBefore time.Time) CertificateOption

func WithSerialNumber added in v1.1.0

func WithSerialNumber(serialNumber *big.Int) CertificateOption

func WithSubject added in v1.1.0

func WithSubject(subject string) CertificateOption

func WithVersion added in v1.1.0

func WithVersion(version int) CertificateOption

type KeyOption added in v1.1.0

type KeyOption interface {
	// contains filtered or unexported methods
}

func WithCurve added in v1.1.0

func WithCurve(curve elliptic.Curve) KeyOption

func WithKeySize added in v1.1.0

func WithKeySize(keySize int) KeyOption

func WithRandom added in v1.1.0

func WithRandom(random io.Reader) KeyOption

type KeyPair

type KeyPair struct {
	PublicKey  any
	PrivateKey any
}

func NewKeyPair

func NewKeyPair(privateKey any) (KeyPair, error)

type KeyPairGenerator

type KeyPairGenerator interface {
	GenerateKeyPair() (KeyPair, error)
}

func GetKeyPairGenerator

func GetKeyPairGenerator(algorithm string, opts ...KeyOption) (KeyPairGenerator, error)

GetKeyPairGenerator returns a KeyPairGenerator The following algorithm are currently supported: ECDSA, RSA, ED25591 Unsupported algorithm result in an error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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