Documentation ¶
Index ¶
- Constants
- Variables
- func BuildCertManagerKeyUsages(ku x509.KeyUsage, eku []x509.ExtKeyUsage) []v1.KeyUsage
- func BuildKeyUsages(usages []v1.KeyUsage, isCA bool) (ku x509.KeyUsage, eku []x509.ExtKeyUsage, err error)
- func DNSNamesForCertificate(crt *v1.Certificate) ([]string, error)
- func DecodePKCS1PrivateKeyBytes(keyBytes []byte) (*rsa.PrivateKey, error)
- func DecodePrivateKeyBytes(keyBytes []byte) (crypto.Signer, error)
- func DecodeX509CertificateBytes(certBytes []byte) (*x509.Certificate, error)
- func DecodeX509CertificateChainBytes(certBytes []byte) ([]*x509.Certificate, error)
- func DecodeX509CertificateRequestBytes(csrBytes []byte) (*x509.CertificateRequest, error)
- func EncodeCSR(template *x509.CertificateRequest, key crypto.Signer) ([]byte, error)
- func EncodeECPrivateKey(pk *ecdsa.PrivateKey) ([]byte, error)
- func EncodePKCS1PrivateKey(pk *rsa.PrivateKey) []byte
- func EncodePKCS8PrivateKey(pk interface{}) ([]byte, error)
- func EncodePrivateKey(pk crypto.PrivateKey, keyEncoding v1.PrivateKeyEncoding) ([]byte, error)
- func EncodeX509(cert *x509.Certificate) ([]byte, error)
- func EncodeX509Chain(certs []*x509.Certificate) ([]byte, error)
- func ExtKeyUsageFromOID(oid asn1.ObjectIdentifier) (eku x509.ExtKeyUsage, ok bool)
- func GenerateCSR(crt *v1.Certificate) (*x509.CertificateRequest, error)
- func GenerateECPrivateKey(keySize int) (*ecdsa.PrivateKey, error)
- func GeneratePrivateKeyForCertificate(crt *v1.Certificate) (crypto.Signer, error)
- func GenerateRSAPrivateKey(keySize int) (*rsa.PrivateKey, error)
- func GenerateTemplate(crt *v1.Certificate) (*x509.Certificate, error)
- func GenerateTemplateFromCSRPEM(csrPEM []byte, duration time.Duration, isCA bool) (*x509.Certificate, error)
- func GenerateTemplateFromCSRPEMWithUsages(csrPEM []byte, duration time.Duration, isCA bool, keyUsage x509.KeyUsage, ...) (*x509.Certificate, error)
- func GenerateTemplateFromCertificateRequest(cr *v1.CertificateRequest) (*x509.Certificate, error)
- func IPAddressesForCertificate(crt *v1.Certificate) []net.IP
- func IPAddressesToString(ipAddresses []net.IP) []string
- func OIDFromExtKeyUsage(eku x509.ExtKeyUsage) (oid asn1.ObjectIdentifier, ok bool)
- func OrganizationForCertificate(crt *v1.Certificate) []string
- func PublicKeyForPrivateKey(pk crypto.PrivateKey) (crypto.PublicKey, error)
- func PublicKeyMatchesCSR(check crypto.PublicKey, csr *x509.CertificateRequest) (bool, error)
- func PublicKeyMatchesCertificate(check crypto.PublicKey, crt *x509.Certificate) (bool, error)
- func PublicKeysEqual(a, b crypto.PublicKey) (bool, error)
- func SignCSRTemplate(caCerts []*x509.Certificate, caKey crypto.Signer, template *x509.Certificate) ([]byte, []byte, error)
- func SignCertificate(template *x509.Certificate, issuerCert *x509.Certificate, ...) ([]byte, *x509.Certificate, error)
- func SignatureAlgorithm(crt *v1.Certificate) (x509.PublicKeyAlgorithm, x509.SignatureAlgorithm, error)
- func SubjectForCertificate(crt *v1.Certificate) v1.X509Subject
- func URIsForCertificate(crt *v1.Certificate) ([]*url.URL, error)
- func URLsFromStrings(urlStrs []string) ([]*url.URL, error)
- func URLsToString(uris []*url.URL) []string
Constants ¶
const ( // MinRSAKeySize is the minimum RSA keysize allowed to be generated by the // generator functions in this package. MinRSAKeySize = 2048 // MaxRSAKeySize is the maximum RSA keysize allowed to be generated by the // generator functions in this package. MaxRSAKeySize = 8192 // ECCurve256 represents a 256bit ECDSA key. ECCurve256 = 256 // ECCurve384 represents a 384bit ECDSA key. ECCurve384 = 384 // ECCurve521 represents a 521bit ECDSA key. ECCurve521 = 521 )
Variables ¶
var ( OIDExtensionKeyUsage = []int{2, 5, 29, 15} OIDExtensionExtendedKeyUsage = []int{2, 5, 29, 37} )
Copied from x509.go
Functions ¶
func BuildCertManagerKeyUsages ¶ added in v1.0.0
func BuildKeyUsages ¶ added in v0.12.0
func DNSNamesForCertificate ¶
func DNSNamesForCertificate(crt *v1.Certificate) ([]string, error)
func DecodePKCS1PrivateKeyBytes ¶
func DecodePKCS1PrivateKeyBytes(keyBytes []byte) (*rsa.PrivateKey, error)
DecodePKCS1PrivateKeyBytes will decode a PEM encoded RSA private key.
func DecodePrivateKeyBytes ¶
DecodePrivateKeyBytes will decode a PEM encoded private key into a crypto.Signer. It supports ECDSA and RSA private keys only. All other types will return err.
func DecodeX509CertificateBytes ¶
func DecodeX509CertificateBytes(certBytes []byte) (*x509.Certificate, error)
DecodeX509CertificateBytes will decode a PEM encoded x509 Certificate.
func DecodeX509CertificateChainBytes ¶ added in v0.6.0
func DecodeX509CertificateChainBytes(certBytes []byte) ([]*x509.Certificate, error)
DecodeX509CertificateChainBytes will decode a PEM encoded x509 Certificate chain.
func DecodeX509CertificateRequestBytes ¶ added in v0.9.0
func DecodeX509CertificateRequestBytes(csrBytes []byte) (*x509.CertificateRequest, error)
DecodeX509CertificateRequestBytes will decode a PEM encoded x509 Certificate Request.
func EncodeCSR ¶
EncodeCSR calls x509.CreateCertificateRequest to sign the given CSR template. It returns a DER encoded signed CSR.
func EncodeECPrivateKey ¶
func EncodeECPrivateKey(pk *ecdsa.PrivateKey) ([]byte, error)
EncodeECPrivateKey will marshal an ECDSA private key into x509 PEM format.
func EncodePKCS1PrivateKey ¶
func EncodePKCS1PrivateKey(pk *rsa.PrivateKey) []byte
EncodePKCS1PrivateKey will marshal a RSA private key into x509 PEM format.
func EncodePKCS8PrivateKey ¶ added in v0.7.0
EncodePKCS8PrivateKey will marshal a private key into x509 PEM format.
func EncodePrivateKey ¶
func EncodePrivateKey(pk crypto.PrivateKey, keyEncoding v1.PrivateKeyEncoding) ([]byte, error)
EncodePrivateKey will encode a given crypto.PrivateKey by first inspecting the type of key encoding and then inspecting the type of key provided. It only supports encoding RSA or ECDSA keys.
func EncodeX509 ¶
func EncodeX509(cert *x509.Certificate) ([]byte, error)
EncodeX509 will encode a *x509.Certificate into PEM format.
func EncodeX509Chain ¶ added in v0.6.0
func EncodeX509Chain(certs []*x509.Certificate) ([]byte, error)
EncodeX509Chain will encode an *x509.Certificate chain into PEM format.
func ExtKeyUsageFromOID ¶ added in v1.0.0
func ExtKeyUsageFromOID(oid asn1.ObjectIdentifier) (eku x509.ExtKeyUsage, ok bool)
func GenerateCSR ¶
func GenerateCSR(crt *v1.Certificate) (*x509.CertificateRequest, error)
GenerateCSR will generate a new *x509.CertificateRequest template to be used by issuers that utilise CSRs to obtain Certificates. The CSR will not be signed, and should be passed to either EncodeCSR or to the x509.CreateCertificateRequest function.
func GenerateECPrivateKey ¶
func GenerateECPrivateKey(keySize int) (*ecdsa.PrivateKey, error)
GenerateECPrivateKey will generate an ECDSA private key of the given size. It can be used to generate 256, 384 and 521 sized keys.
func GeneratePrivateKeyForCertificate ¶
func GeneratePrivateKeyForCertificate(crt *v1.Certificate) (crypto.Signer, error)
GeneratePrivateKeyForCertificate will generate a private key suitable for the provided cert-manager Certificate resource, taking into account the parameters on the provided resource. The returned key will either be RSA or ECDSA.
func GenerateRSAPrivateKey ¶
func GenerateRSAPrivateKey(keySize int) (*rsa.PrivateKey, error)
GenerateRSAPrivateKey will generate a RSA private key of the given size. It places restrictions on the minimum and maximum RSA keysize.
func GenerateTemplate ¶
func GenerateTemplate(crt *v1.Certificate) (*x509.Certificate, error)
GenerateTemplate will create a x509.Certificate for the given Certificate resource. This should create a Certificate template that is equivalent to the CertificateRequest generated by GenerateCSR. The PublicKey field must be populated by the caller.
func GenerateTemplateFromCSRPEM ¶ added in v0.10.0
func GenerateTemplateFromCSRPEMWithUsages ¶ added in v0.10.0
func GenerateTemplateFromCertificateRequest ¶ added in v0.9.0
func GenerateTemplateFromCertificateRequest(cr *v1.CertificateRequest) (*x509.Certificate, error)
GenerateTemplate will create a x509.Certificate for the given CertificateRequest resource
func IPAddressesForCertificate ¶ added in v0.7.0
func IPAddressesForCertificate(crt *v1.Certificate) []net.IP
func IPAddressesToString ¶ added in v0.7.0
func OIDFromExtKeyUsage ¶ added in v1.0.0
func OIDFromExtKeyUsage(eku x509.ExtKeyUsage) (oid asn1.ObjectIdentifier, ok bool)
OIDFromExtKeyUsage returns the ASN1 Identifier for a x509.ExtKeyUsage
func OrganizationForCertificate ¶
func OrganizationForCertificate(crt *v1.Certificate) []string
OrganizationForCertificate will return the Organization to set for the Certificate resource. If an Organization is not specifically set, a default will be used.
func PublicKeyForPrivateKey ¶
func PublicKeyForPrivateKey(pk crypto.PrivateKey) (crypto.PublicKey, error)
PublicKeyForPrivateKey will return the crypto.PublicKey for the given crypto.PrivateKey. It only supports RSA and ECDSA keys.
func PublicKeyMatchesCSR ¶
PublicKeyMatchesCSR can be used to verify the given public key is the correct counter-part to the given x509 CertificateRequest. It will return false and no error if the public key is *not* valid for the given CertificateRequest. It will return true if the public key *is* valid for the given CertificateRequest. It will return an error if either of the passed parameters are of an unrecognised type (i.e. non RSA/ECDSA)
func PublicKeyMatchesCertificate ¶
PublicKeyMatchesCertificate can be used to verify the given public key is the correct counter-part to the given x509 Certificate. It will return false and no error if the public key is *not* valid for the given Certificate. It will return true if the public key *is* valid for the given Certificate. It will return an error if either of the passed parameters are of an unrecognised type (i.e. non RSA/ECDSA)
func SignCSRTemplate ¶ added in v0.9.0
func SignCSRTemplate(caCerts []*x509.Certificate, caKey crypto.Signer, template *x509.Certificate) ([]byte, []byte, error)
SignCSRTemplate signs a certificate template usually based upon a CSR. This function expects all fields to be present in the certificate template, including it's public key. It returns the certificate data followed by the CA data, encoded in PEM format.
func SignCertificate ¶
func SignCertificate(template *x509.Certificate, issuerCert *x509.Certificate, publicKey crypto.PublicKey, signerKey interface{}) ([]byte, *x509.Certificate, error)
SignCertificate returns a signed x509.Certificate object for the given *v1.Certificate crt. publicKey is the public key of the signee, and signerKey is the private key of the signer. It returns a PEM encoded copy of the Certificate as well as a *x509.Certificate which can be used for reading the encoded values.
func SignatureAlgorithm ¶
func SignatureAlgorithm(crt *v1.Certificate) (x509.PublicKeyAlgorithm, x509.SignatureAlgorithm, error)
SignatureAlgorithm will determine the appropriate signature algorithm for the given certificate. Adapted from https://github.com/cloudflare/cfssl/blob/master/csr/csr.go#L102
func SubjectForCertificate ¶ added in v0.13.0
func SubjectForCertificate(crt *v1.Certificate) v1.X509Subject
SubjectForCertificate will return the Subject from the Certificate resource or an empty one if it is not set
func URIsForCertificate ¶ added in v0.11.0
func URIsForCertificate(crt *v1.Certificate) ([]*url.URL, error)
func URLsToString ¶ added in v0.11.0
Types ¶
This section is empty.