Documentation
¶
Index ¶
- Constants
- func AllPKCS12Formats() []string
- func CreateCSR(privateKey crypto.Signer, opts CSROptions) ([]byte, error)
- func ExtractDomains(cert *x509.Certificate) []string
- func ExtractDomainsCSR(csr *x509.CertificateRequest) []string
- func GeneratePemCert(privateKey *rsa.PrivateKey, domain string, extensions []pkix.Extension) ([]byte, error)
- func GeneratePrivateKey(keyType KeyType) (crypto.Signer, error)
- func GetCSRMainDomain(cert *x509.CertificateRequest) (string, error)
- func GetCertificateMainDomain(cert *x509.Certificate) (string, error)
- func GetPKCS12Encoder(format string) (*pkcs12.Encoder, error)
- func IsPKCS12Supported(format string) bool
- func IsSupported(keyType KeyType) bool
- func PEMBlock(data any) *pem.Block
- func PEMEncode(data any) []byte
- func ParsePEMBundle(bundle []byte) ([]*x509.Certificate, error)
- func ParsePEMCertificate(cert []byte) (*x509.Certificate, error)
- func ParsePEMPrivateKey(key []byte) (crypto.Signer, error)
- func PemDecodeTox509CSR(data []byte) (*x509.CertificateRequest, error)
- type CSROptions
- type DERCertificateBytes
- type KeyType
- func AllKeyTypes() []KeyType
- func GetCSRKeyType(csr *x509.CertificateRequest) (KeyType, error)
- func GetCertificateKeyType(cert *x509.Certificate) (KeyType, error)
- func GetKeyType(key any) (KeyType, error)
- func GetPrivateKeyType(signer crypto.Signer) (KeyType, error)
- func ToKeyType(keyType string) (KeyType, error)
Constants ¶
const ( // OCSPGood means that the certificate is valid. OCSPGood = ocsp.Good // OCSPRevoked means that the certificate has been deliberately revoked. OCSPRevoked = ocsp.Revoked // OCSPUnknown means that the OCSP responder doesn't know about the certificate. OCSPUnknown = ocsp.Unknown // OCSPServerFailed means that the OCSP responder failed to process the request. OCSPServerFailed = ocsp.ServerFailed )
const ( EC256 = KeyType("EC256") EC384 = KeyType("EC384") RSA2048 = KeyType("RSA2048") RSA3072 = KeyType("RSA3072") RSA4096 = KeyType("RSA4096") RSA8192 = KeyType("RSA8192") )
Constants for all key types we support.
const ( PKCS12LegacyDES = "DES" PKCS12LegacyRC2 = "RC2" PKCS12Modern2023 = "SHA256" PKCS12Modern2026 = "PBMAC1" )
Constants for all PKCS#12 encryption format we support.
Variables ¶
This section is empty.
Functions ¶
func AllPKCS12Formats ¶
func AllPKCS12Formats() []string
func ExtractDomains ¶
func ExtractDomains(cert *x509.Certificate) []string
func ExtractDomainsCSR ¶
func ExtractDomainsCSR(csr *x509.CertificateRequest) []string
func GeneratePemCert ¶
func GetCSRMainDomain ¶
func GetCSRMainDomain(cert *x509.CertificateRequest) (string, error)
func GetCertificateMainDomain ¶
func GetCertificateMainDomain(cert *x509.Certificate) (string, error)
func GetPKCS12Encoder ¶
GetPKCS12Encoder returns a PKCS12 encoder based on the provided format.
func IsPKCS12Supported ¶
IsPKCS12Supported checks if the provided format is a supported PKCS#12 encryption format.
func IsSupported ¶
IsSupported checks if the key type is supported.
func ParsePEMBundle ¶
func ParsePEMBundle(bundle []byte) ([]*x509.Certificate, error)
ParsePEMBundle parses a certificate bundle from top to bottom and returns a slice of x509 certificates. This function will error if no certificates are found.
func ParsePEMCertificate ¶
func ParsePEMCertificate(cert []byte) (*x509.Certificate, error)
ParsePEMCertificate returns Certificate from a PEM encoded certificate. The certificate has to be PEM encoded. Any other encodings like DER will fail.
func ParsePEMPrivateKey ¶
ParsePEMPrivateKey parses a private key from key, which is a PEM block. Borrowed from Go standard library, to handle various private key and PEM block types. https://github.com/golang/go/blob/693748e9fa385f1e2c3b91ca9acbb6c0ad2d133d/src/crypto/tls/tls.go#L291-L308 https://github.com/golang/go/blob/693748e9fa385f1e2c3b91ca9acbb6c0ad2d133d/src/crypto/tls/tls.go#L238
func PemDecodeTox509CSR ¶
func PemDecodeTox509CSR(data []byte) (*x509.CertificateRequest, error)
Types ¶
type CSROptions ¶
type DERCertificateBytes ¶
type DERCertificateBytes []byte
type KeyType ¶
type KeyType string
KeyType represents the key algo as well as the key size or curve to use.
func AllKeyTypes ¶
func AllKeyTypes() []KeyType
func GetCSRKeyType ¶
func GetCSRKeyType(csr *x509.CertificateRequest) (KeyType, error)
GetCSRKeyType gets the key type based on the public key from x509.CertificateRequest.
func GetCertificateKeyType ¶
func GetCertificateKeyType(cert *x509.Certificate) (KeyType, error)
GetCertificateKeyType gets the key type based on the public key from x509.Certificate.
func GetPrivateKeyType ¶
GetPrivateKeyType gets the key type based on the public key from crypto.Signer.