Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultCountry = "CN" DefaultOrganization = "guoyk93.github.io" DefaultExpires = time.Hour * 24 * 365 * 30 DefaultPublicKeyAlgorithm = x509.RSA )
View Source
const ( PEMTypeCertificate = "CERTIFICATE" PEMTypeRSAPrivateKey = "RSA PRIVATE KEY" PEMTypePrivateKey = "PRIVATE KEY" )
Variables ¶
This section is empty.
Functions ¶
func CreateCertificatePEM ¶
func CreateCertificatePEM(template, parent *x509.Certificate, pub any, priv any) (crt *x509.Certificate, crtPEM []byte, err error)
CreateCertificatePEM create certificate with PEM output
func GeneratePrivateKeyPEM ¶
func GeneratePrivateKeyPEM(alg x509.PublicKeyAlgorithm) (key crypto.Signer, keyPEM []byte, err error)
GeneratePrivateKeyPEM generate a private key with PEM output in PKCS8 format
Types ¶
type GenerateOptions ¶
type GenerateOptions struct { // Parent certificate of parent, required when IsCA is false Parent PEMPair // IsCA whether to generate a IsCA certificate IsCA bool // PublicKeyAlgorithm x509 public key algorithm, default to RSA PublicKeyAlgorithm x509.PublicKeyAlgorithm // Names certificate names, tailing names will be used as DNSNames Names []string // Country certificate country Country string // Organization certificate organization Organization string // Expires certificate duration Expires time.Duration }
GenerateOptions options for certificate generation
type PEMPair ¶
PEMPair PEM encoded x509 key pair
func Generate ¶
func Generate(opts GenerateOptions) (res PEMPair, err error)
Generate easily generate a certificate with RSA private key if both ParentCrtPEM and CAKeyPem is missing, will generate a new IsCA
func (PEMPair) Certificate ¶
func (b PEMPair) Certificate() (crt *x509.Certificate, err error)
func (PEMPair) PrivateKey ¶
Click to show internal directories.
Click to hide internal directories.