certificate

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package certificate contains functions to load an Apple APNs PKCS#12 or PEM certificate from either an in memory byte array or a local file.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToDecryptKey       = errors.New("failed to decrypt private key")
	ErrFailedToParsePrivateKey  = errors.New("failed to parse private key")
	ErrFailedToParseCertificate = errors.New("failed to parse certificate PEM data")
	ErrNoPrivateKey             = errors.New("no private key")
	ErrNoCertificate            = errors.New("no certificate")
)

Possible errors when parsing a certificate.

Functions

func FromP12Bytes

func FromP12Bytes(bytes []byte, password string) (tls.Certificate, error)

FromP12Bytes loads a PKCS#12 certificate from an in memory byte array and returns a tls.Certificate.

This function adds support to load p12 files with cert and key combined as well as password protected keys which are both common with APNs certificates. Usually you should generate a pem file with p12 file to avoid a p12 file that is incorporated with a root certificate. For more details, go to https://github.com/golang/go/issues/14015.

Use "" as the password argument if the PKCS#12 certificate is not password protected.

func FromP12File

func FromP12File(filename string, password string) (tls.Certificate, error)

FromP12File loads a PKCS#12 certificate from a local file and returns a tls.Certificate.

Use "" as the password argument if the PKCS#12 certificate is not password protected.

func FromPemBytes

func FromPemBytes(bytes []byte, password string) (tls.Certificate, error)

FromPemBytes loads a PEM certificate from an in memory byte array and returns a tls.Certificate. This function is similar to the crypto/tls X509KeyPair function, however it supports PEM files with the cert and key combined, as well as password protected keys which are both common with APNs certificates.

Use "" as the password argument if the PEM certificate is not password protected.

func FromPemFile

func FromPemFile(filename string, password string) (tls.Certificate, error)

FromPemFile loads a PEM certificate from a local file and returns a tls.Certificate. This function is similar to the crypto/tls LoadX509KeyPair function, however it supports PEM files with the cert and key combined in the same file, as well as password protected key files which are both common with APNs certificates.

Use "" as the password argument if the PEM certificate is not password protected.

Types

This section is empty.

Jump to

Keyboard shortcuts

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