Documentation
¶
Index ¶
- func LoadAllCertPool(additionalCAFiles []string) (*x509.CertPool, error)
- func LoadCertPoolFromFile(file string) (*x509.CertPool, error)
- func LoadCertPoolFromPEM(caBytes []byte) (*x509.CertPool, error)
- func LoadCertificateFromFile(file string) (*tls.Certificate, error)
- func LoadKeyAndCertificate(keyBytes []byte, certBytes []byte) (*tls.Certificate, error)
- func LoadKeyAndCertificateFromFile(keyPath, certPath string) (*tls.Certificate, error)
- func LoadKeyFromFile(file string) (crypto.PrivateKey, error)
- func UnmarshalCert(certBytes []byte) (*tls.Certificate, error)
- func UnmarshalPemKey(keyBytes []byte) (crypto.PrivateKey, error)
- type Descriptor
- type EncodeType
- type SelfSigner
- func (g *SelfSigner) CACert() []byte
- func (g *SelfSigner) CAPrivateKey() []byte
- func (g *SelfSigner) CreateSelfSigned(info *x509.Certificate) (cert, key []byte, err error)
- func (g *SelfSigner) CreateSelfSignedCertificates(descriptors []*Descriptor) (error, int)
- func (g *SelfSigner) GenerateCA(info *x509.Certificate) error
- func (g *SelfSigner) LoadCAFromBuf(certPEM, keyPEM []byte) error
- func (g *SelfSigner) LoadCAFromFiles(certFile, keyFile string) error
- func (g *SelfSigner) UseAlgorithm(alg elliptic.Curve)
- func (g *SelfSigner) UseRandProvider(rand io.Reader)
- func (g *SelfSigner) UseSerialNumberGenerator(gen SerialNumberGenerator)
- func (g *SelfSigner) WriteCACertFiles(file string) error
- func (g *SelfSigner) WriteFiles(descriptors []*Descriptor) error
- type SerialNumberGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadAllCertPool ¶
LoadAllCertPool loads system default pool and appends the additional ca certs provided in additionalCAFiles to the pool. The additional ca cert files are expected to be PEM-encoded. Returns the system pool plus the additional.
func LoadCertPoolFromFile ¶
LoadCertPoolFromFile loads certs from the ca file and returns as a new cert pool. The system cert pool is not loaded and caBytes should be PEM-encoded.
func LoadCertPoolFromPEM ¶
LoadCertPoolFromPEM loads certs from the ca certificate and returns as a new cert pool. The system cert pool is not loaded and caBytes should be PEM-encoded.
func LoadCertificateFromFile ¶
func LoadCertificateFromFile(file string) (*tls.Certificate, error)
LoadCertificateFromFile loads a single PEM-encoded cert from the file.
func LoadKeyAndCertificate ¶
func LoadKeyAndCertificate(keyBytes []byte, certBytes []byte) (*tls.Certificate, error)
LoadKeyAndCertificate combines a tls.Certificate using the given cert and key binary data.
func LoadKeyAndCertificateFromFile ¶
func LoadKeyAndCertificateFromFile(keyPath, certPath string) (*tls.Certificate, error)
LoadKeyAndCertificateFromFile loads key and cert for a single pair.
func LoadKeyFromFile ¶
func LoadKeyFromFile(file string) (crypto.PrivateKey, error)
LoadKeyFromFile loads a single PMM-encoded private key from the file.
func UnmarshalCert ¶
func UnmarshalCert(certBytes []byte) (*tls.Certificate, error)
UnmarshalCert unmarshal binary data to a tls.Certificate.
func UnmarshalPemKey ¶
func UnmarshalPemKey(keyBytes []byte) (crypto.PrivateKey, error)
UnmarshalPemKey unmarshal binary data to a crypto.PrivateKey
Types ¶
type Descriptor ¶
type Descriptor struct { Name string //file name Info *x509.Certificate //basic input info EncodeType EncodeType CertEncoded []byte KeyEncoded []byte }
Descriptor defines
type SelfSigner ¶
type SelfSigner struct {
// contains filtered or unexported fields
}
func NewSelfSigner ¶
func NewSelfSigner() *SelfSigner
func (*SelfSigner) CACert ¶
func (g *SelfSigner) CACert() []byte
CACert returns the PEM-encoded ca certificate data.
func (*SelfSigner) CAPrivateKey ¶
func (g *SelfSigner) CAPrivateKey() []byte
CAPrivateKey returns the PEM-encoded ca private key data.
func (*SelfSigner) CreateSelfSigned ¶
func (g *SelfSigner) CreateSelfSigned(info *x509.Certificate) (cert, key []byte, err error)
CreateSelfSigned creates a certificate based on the given input. The following fields input are extracted:
NotBefore - mandatory NotAfter - mandatory Subject - mandatory IPAddresses - optional EmailAddresses - optional DNSNames - optional
func (*SelfSigner) CreateSelfSignedCertificates ¶
func (g *SelfSigner) CreateSelfSignedCertificates(descriptors []*Descriptor) (error, int)
CreateSelfSignedCertificates creates and signs certificates according to the given descriptors and returns number of certificates successfully generated.
func (*SelfSigner) GenerateCA ¶
func (g *SelfSigner) GenerateCA(info *x509.Certificate) error
GenerateCA creates a deterministic certificate authority. The following fields input are extracted:
NotBefore - mandatory NotAfter - mandatory Subject - mandatory IPAddresses - optional EmailAddresses - optional
func (*SelfSigner) LoadCAFromBuf ¶
func (g *SelfSigner) LoadCAFromBuf(certPEM, keyPEM []byte) error
LoadCAFromBuf loads certificate and private key data from the given slices. Note that both are required to be PEM-encoded.
func (*SelfSigner) LoadCAFromFiles ¶
func (g *SelfSigner) LoadCAFromFiles(certFile, keyFile string) error
LoadCAFromFiles loads certificate and private key data from the given file path. Note that both are required to be PEM-encoded.
func (*SelfSigner) UseAlgorithm ¶
func (g *SelfSigner) UseAlgorithm(alg elliptic.Curve)
func (*SelfSigner) UseRandProvider ¶
func (g *SelfSigner) UseRandProvider(rand io.Reader)
func (*SelfSigner) UseSerialNumberGenerator ¶
func (g *SelfSigner) UseSerialNumberGenerator(gen SerialNumberGenerator)
func (*SelfSigner) WriteCACertFiles ¶
func (g *SelfSigner) WriteCACertFiles(file string) error
func (*SelfSigner) WriteFiles ¶
func (g *SelfSigner) WriteFiles(descriptors []*Descriptor) error