Documentation
¶
Index ¶
- Variables
- func LoadCertificate(path string) (*x509.Certificate, error)
- func LoadCertificateWithPassword(path string, password []byte) (*x509.Certificate, error)
- func LoadPrivateKey(path string) (crypto.PrivateKey, error)
- func LoadPrivateKeyWithPassword(path string, password []byte) (crypto.PrivateKey, error)
- func LoadPublicKey(path string) (crypto.PublicKey, error)
- func LoadPublicKeyWithPassword(path string, password []byte) (crypto.PublicKey, error)
- func ParseCertificateFromDERBytes(derBytes []byte) (*x509.Certificate, error)
- func ParseCertificateFromEncryptedPEMBytes(pemBytes []byte, password []byte) (*x509.Certificate, error)
- func ParseCertificateFromPEMBytes(pemBytes []byte) (*x509.Certificate, error)
- func ParsePrivateKeyFromDERBytes(derBytes []byte) (crypto.PrivateKey, error)
- func ParsePrivateKeyFromEncryptedPEMBytes(pemBytes []byte, password []byte) (crypto.PrivateKey, error)
- func ParsePrivateKeyFromPEMBytes(pemBytes []byte) (crypto.PrivateKey, error)
- func ParsePublicKeyFromDERBytes(derBytes []byte) (crypto.PublicKey, error)
- func ParsePublicKeyFromEncryptedPEMBytes(pemBytes []byte, password []byte) (crypto.PublicKey, error)
- func ParsePublicKeyFromPEMBytes(pemBytes []byte) (crypto.PublicKey, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCertificateMustBePEMEncoded indicates that a given data block was not a PEM encoded block. ErrCertificateMustBePEMEncoded = errors.New("invalid Certificate: Certificate must be PEM encoded") // ErrNotACertificate indicates that a given PEM block did not contain a known certificate format. ErrNotACertificate = errors.New("invalid Key: PEM block must be a x509 certificate") )
var ( // ErrKeyMustBePEMEncoded indicates that a given data block was not a PEM encoded block. ErrKeyMustBePEMEncoded = errors.New("invalid Key: Key must be PEM encoded") // ErrNotAPrivateKey indicates that a given PEM block did not contain a known private key format. ErrNotAPrivateKey = errors.New("invalid Key: PEM block must be a PKCS #1, PKCS #8 or SEC 1 private key") // ErrUnknownEncryption indicates that the given PEM block was not encrypted in a known format, // or not encrypted in the first place. ErrUnknownEncryption = errors.New("invalid encryption: PEM block is encrypted in a unknown format, or not encrypted at all") )
var ( // ErrNotAPublicKey indicates that a given PEM block did not contain a known public key format. ErrNotAPublicKey = errors.New("invalid Key: PEM block must be a PKIX or PKCS #1 public key") )
Functions ¶
func LoadCertificate ¶ added in v1.1.0
func LoadCertificate(path string) (*x509.Certificate, error)
LoadCertificate tries to load a certificate from a given path.
func LoadCertificateWithPassword ¶ added in v1.1.0
func LoadCertificateWithPassword(path string, password []byte) (*x509.Certificate, error)
LoadCertificateWithPassword tries to load a certificate from a given path with a password.
func LoadPrivateKey ¶
func LoadPrivateKey(path string) (crypto.PrivateKey, error)
LoadPrivateKey tries to load a private key from a given path.
func LoadPrivateKeyWithPassword ¶
func LoadPrivateKeyWithPassword(path string, password []byte) (crypto.PrivateKey, error)
LoadPrivateKeyWithPassword tries to load a private key from a given path with a password.
func LoadPublicKey ¶
LoadPublicKey tries to load a public key from a given path.
func LoadPublicKeyWithPassword ¶
LoadPublicKeyWithPassword tries to load a public key from a given path with a password.
func ParseCertificateFromDERBytes ¶ added in v1.1.0
func ParseCertificateFromDERBytes(derBytes []byte) (*x509.Certificate, error)
ParseCertificateFromDERBytes parse a given byte array for a ASN.1 DER encoded PKIX or PKCS #1 public key. Will return ErrNotACertificate if the given byte array is not in properly encoded DER form, or is not a known public key format.
func ParseCertificateFromEncryptedPEMBytes ¶ added in v1.1.0
func ParseCertificateFromEncryptedPEMBytes(pemBytes []byte, password []byte) (*x509.Certificate, error)
ParseCertificateFromEncryptedPEMBytes parses and decrypts a given byte array and password to a PEM block, and parses that block for a known certificate. Will return ErrCertificateMustBePEMEncoded if the given byte array is not a valid PEM block, or ErrUnknownEncryption if the byte array was encrypted in an unknown format, or not encrypted at all. Note: Usage of RFC 1423 encrypted PEM blocks is deprecated since Go 1.16!
func ParseCertificateFromPEMBytes ¶ added in v1.1.0
func ParseCertificateFromPEMBytes(pemBytes []byte) (*x509.Certificate, error)
ParseCertificateFromPEMBytes parses a given byte array to a PEM block, and parses that block for a known certificate. Will return ErrCertificateMustBePEMEncoded if the given byte array is not a valid PEM block.
func ParsePrivateKeyFromDERBytes ¶
func ParsePrivateKeyFromDERBytes(derBytes []byte) (crypto.PrivateKey, error)
ParsePrivateKeyFromDERBytes parse a given byte array for a ASN.1 DER encoded PKCS #1, PKCS #8 or SEC 1 private key. Will return ErrNotAPrivateKey if the given byte array is not in properly encoded DER form, or is not a known private key format.
func ParsePrivateKeyFromEncryptedPEMBytes ¶
func ParsePrivateKeyFromEncryptedPEMBytes(pemBytes []byte, password []byte) (crypto.PrivateKey, error)
ParsePrivateKeyFromEncryptedPEMBytes parses and decrypts a given byte array and password to a PEM block, and parses that block for a known private key (see ParsePrivateKeyFromDERBytes). Will return ErrKeyMustBePEMEncoded if the given byte array is not a valid PEM block, or ErrUnknownEncryption if the byte array was encrypted in an unknown format, or not encrypted at all. Note: Usage of RFC 1423 encrypted PEM blocks is deprecated since Go 1.16! Use PKCS #8 instead.
func ParsePrivateKeyFromPEMBytes ¶
func ParsePrivateKeyFromPEMBytes(pemBytes []byte) (crypto.PrivateKey, error)
ParsePrivateKeyFromPEMBytes parses a given byte array to a PEM block, and parses that block for a known private key (see ParsePrivateKeyFromDERBytes). Will return ErrKeyMustBePEMEncoded if the given byte array is not a valid PEM block.
func ParsePublicKeyFromDERBytes ¶
ParsePublicKeyFromDERBytes parse a given byte array for a ASN.1 DER encoded PKIX or PKCS #1 public key. Will return ErrNotAPublicKey if the given byte array is not in properly encoded DER form, or is not a known public key format.
func ParsePublicKeyFromEncryptedPEMBytes ¶
func ParsePublicKeyFromEncryptedPEMBytes(pemBytes []byte, password []byte) (crypto.PublicKey, error)
ParsePublicKeyFromEncryptedPEMBytes parses and decrypts a given byte array and password to a PEM block, and parses that block for a known public key (see ParsePublicKeyFromDERBytes). Will return ErrKeyMustBePEMEncoded if the given byte array is not a valid PEM block, or ErrUnknownEncryption if the byte array was encrypted in an unknown format, or not encrypted at all. Note: Usage of RFC 1423 encrypted PEM blocks is deprecated since Go 1.16!
func ParsePublicKeyFromPEMBytes ¶
ParsePublicKeyFromPEMBytes parses a given byte array to a PEM block, and parses that block for a known public key (see ParsePublicKeyFromDERBytes). Will return ErrKeyMustBePEMEncoded if the given byte array is not a valid PEM block.
Types ¶
This section is empty.