Documentation ¶
Index ¶
- func DecodeCert(encodedCert []byte) (*x509.Certificate, error)
- func DecodeKey(encodedKey []byte) (*rsa.PrivateKey, error)
- func EncodeCert(cert *x509.Certificate) []byte
- func EncodeKey(key *rsa.PrivateKey) []byte
- func NewCACertificate(key *rsa.PrivateKey) (*x509.Certificate, error)
- func NewPrivateKey() (*rsa.PrivateKey, error)
- type CA
- func (ca *CA) Certificate() *x509.Certificate
- func (ca *CA) EncodedCertificate() []byte
- func (ca *CA) EncodedKey() []byte
- func (ca *CA) GenerateCertificate(cn string, key crypto.PublicKey) (*x509.Certificate, error)
- func (ca *CA) GenerateCertificateWithDuration(cn string, notBefore, notAfter time.Time, key crypto.PublicKey) (*x509.Certificate, error)
- func (ca *CA) PrivateKey() *rsa.PrivateKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeCert ¶
func DecodeCert(encodedCert []byte) (*x509.Certificate, error)
DecodeCert return the decoded certificate of given encodedCert
func DecodeKey ¶
func DecodeKey(encodedKey []byte) (*rsa.PrivateKey, error)
DecodeKey returns the decoded private key of given encodedKey
func EncodeCert ¶
func EncodeCert(cert *x509.Certificate) []byte
EncodeCert returns PEM encoding of given cert
func EncodeKey ¶
func EncodeKey(key *rsa.PrivateKey) []byte
EncodeKey returns PEM encoding of give private key
func NewCACertificate ¶
func NewCACertificate(key *rsa.PrivateKey) (*x509.Certificate, error)
NewCACertificate returns a self-signed certificate used as certificate authority
func NewPrivateKey ¶
func NewPrivateKey() (*rsa.PrivateKey, error)
NewPrivateKey generate an rsa private key
Types ¶
type CA ¶
type CA struct {
// contains filtered or unexported fields
}
CA type representation for a self-signed certificate authority
func NewCA ¶
func NewCA(caCert *x509.Certificate, key *rsa.PrivateKey) (*CA, error)
NewCA creates a new CA object for given CA certificate and private key. If both of caCert and key are nil, generates a new private key and a self-signed certificate
func (*CA) Certificate ¶
func (ca *CA) Certificate() *x509.Certificate
Certificate returns root ca certificate used
func (*CA) EncodedCertificate ¶
EncodedCertificate returns encoded root ca certificate used
func (*CA) EncodedKey ¶
EncodedKey returns encoded private key used
func (*CA) GenerateCertificate ¶
GenerateCertificate returns a new certificate signed for given public key.
func (*CA) GenerateCertificateWithDuration ¶
func (ca *CA) GenerateCertificateWithDuration(cn string, notBefore, notAfter time.Time, key crypto.PublicKey) (*x509.Certificate, error)
GenerateCertificateWithDuration returns a new certificate signed for given public key. The duration of this certificate is with in the given notBefore and notAfter bounds. Intended use of this API is only by tests
func (*CA) PrivateKey ¶
func (ca *CA) PrivateKey() *rsa.PrivateKey
PrivateKey returns private key used