Documentation ¶
Overview ¶
Package certs provides functions for X.509 certificate management.
Index ¶
- Constants
- func BasicConstraintsString(isCA bool, maxPathLen int, maxPathLenZero bool) string
- func ExportDER(out io.Writer, certificate *x509.Certificate, chain []*x509.Certificate, ...) error
- func ExportPEM(out io.Writer, certificate *x509.Certificate, chain []*x509.Certificate, ...) error
- func ExportPKCS12(out io.Writer, certificate *x509.Certificate, chain []*x509.Certificate, ...) error
- func ExtKeyUsageString(extKeyUsage []x509.ExtKeyUsage, unknownExtKeyUsage []asn1.ObjectIdentifier) string
- func FetchCertificates(url string) ([]*x509.Certificate, error)
- func IsIssuedBy(cert *x509.Certificate, issuer *x509.Certificate) bool
- func IsRoot(cert *x509.Certificate) bool
- func KeyIdentifierString(keyId []byte) string
- func KeyUsageString(keyUsage x509.KeyUsage) string
- func ParseDN(dn string) (*pkix.Name, error)
- func RawExtensionString(extension []byte) string
- func ReadCertificates(in io.Reader) ([]*x509.Certificate, error)
- func ReadCertificatesFile(filename string) ([]*x509.Certificate, error)
- func ServerCertificates(network string, addr string) ([]*x509.Certificate, error)
- func WriteCertificatesDER(out io.Writer, certificates []*x509.Certificate) error
- func WriteCertificatesDERFile(filename string, certificates []*x509.Certificate, perm os.FileMode) error
- func WriteCertificatesPEM(out io.Writer, certificates []*x509.Certificate) error
- func WriteCertificatesPEMFile(filename string, certificates []*x509.Certificate, perm os.FileMode) error
- type CertificateFactory
- func NewACMECertificateFactory(certificateRequest *acme.CertificateRequest, ...) CertificateFactory
- func NewLocalCertificateFactory(template *x509.Certificate, keyPairFactory keys.KeyPairFactory, ...) CertificateFactory
- func NewRemoteCertificateFactory(template *x509.Certificate, request *x509.CertificateRequest, ...) CertificateFactory
- type CertificateRequestFactory
- type RevocationListFactory
Constants ¶
const AuthorityKeyIdentifierExtensionName = "AuthorityKeyIdentifier"
const AuthorityKeyIdentifierExtensionOID = "2.5.29.35"
const BasicConstraintsExtensionName = "BasicConstraints"
const BasicConstraintsExtensionOID = "2.5.29.19"
const ExtKeyUsageExtensionName = "ExtKeyUsage"
const ExtKeyUsageExtensionOID = "2.5.29.37"
const KeyUsageExtensionName = "KeyUsage"
const KeyUsageExtensionOID = "2.5.29.15"
const SubjectKeyIdentifierExtensionName = "SubjectKeyIdentifier"
const SubjectKeyIdentifierExtensionOID = "2.5.29.14"
Variables ¶
This section is empty.
Functions ¶
func BasicConstraintsString ¶ added in v0.0.4
func ExportDER ¶ added in v0.0.9
func ExportDER(out io.Writer, certificate *x509.Certificate, chain []*x509.Certificate, key crypto.PrivateKey) error
func ExportPEM ¶ added in v0.0.9
func ExportPEM(out io.Writer, certificate *x509.Certificate, chain []*x509.Certificate, key crypto.PrivateKey) error
func ExportPKCS12 ¶ added in v0.0.9
func ExportPKCS12(out io.Writer, certificate *x509.Certificate, chain []*x509.Certificate, key crypto.PrivateKey, password string) error
func ExtKeyUsageString ¶ added in v0.0.4
func ExtKeyUsageString(extKeyUsage []x509.ExtKeyUsage, unknownExtKeyUsage []asn1.ObjectIdentifier) string
func FetchCertificates ¶
func FetchCertificates(url string) ([]*x509.Certificate, error)
FetchCertificates fetches X.509 certificates from the given URL.
func IsIssuedBy ¶
func IsIssuedBy(cert *x509.Certificate, issuer *x509.Certificate) bool
IsIssuedBy checks whether the given certificate has been issued/signed by the given issuer certificate.
func IsRoot ¶
func IsRoot(cert *x509.Certificate) bool
IsRoot checks whether the given certificate is a root certificate.
func KeyIdentifierString ¶ added in v0.0.4
func KeyUsageString ¶ added in v0.0.4
func RawExtensionString ¶ added in v0.0.7
func ReadCertificates ¶
func ReadCertificates(in io.Reader) ([]*x509.Certificate, error)
ReadCertificates reads X.509 certificates from the given io.Reader.
func ReadCertificatesFile ¶ added in v0.0.9
func ReadCertificatesFile(filename string) ([]*x509.Certificate, error)
ReadCertificatesFile reads X.509 certificates from the given file name.
func ServerCertificates ¶
func ServerCertificates(network string, addr string) ([]*x509.Certificate, error)
ServerCertificates gets the X.509 certificates used for encrypting the connection to the given server.
The server protocol must be TLS based (e.g. https, ldaps). The certificates are retrieved during the TLS handshake.
func WriteCertificatesDER ¶
func WriteCertificatesDER(out io.Writer, certificates []*x509.Certificate) error
WriteCertificatesDER writes X.509 certificates in DER format to the given io.Writer.
func WriteCertificatesDERFile ¶ added in v0.0.9
func WriteCertificatesDERFile(filename string, certificates []*x509.Certificate, perm os.FileMode) error
WriteCertificatesDERFile writes X.509 certificates in DER format to the given file.
func WriteCertificatesPEM ¶
func WriteCertificatesPEM(out io.Writer, certificates []*x509.Certificate) error
WriteCertificatesPEM writes X.509 certificates in PEM format to the given io.Writer.
func WriteCertificatesPEMFile ¶ added in v0.0.9
func WriteCertificatesPEMFile(filename string, certificates []*x509.Certificate, perm os.FileMode) error
WriteCertificatesPEMFile writes X.509 certificates in PEM format to the given file name.
Types ¶
type CertificateFactory ¶
type CertificateFactory interface { // Name returns the name of this factory. Name() string // New creates a new X.509 certificate. New() (crypto.PrivateKey, *x509.Certificate, error) }
CertificateFactory interface provides a unified way to create X.509 certificates.
func NewACMECertificateFactory ¶
func NewACMECertificateFactory(certificateRequest *acme.CertificateRequest, keyPairFactory keys.KeyPairFactory) CertificateFactory
NewACMECertificateFactory creates a new certificate factory for ACME based certificates.
func NewLocalCertificateFactory ¶
func NewLocalCertificateFactory(template *x509.Certificate, keyPairFactory keys.KeyPairFactory, parent *x509.Certificate, signer crypto.PrivateKey) CertificateFactory
NewLocalCertificateFactory creates a new certificate factory for locally issued certificates.
func NewRemoteCertificateFactory ¶
func NewRemoteCertificateFactory(template *x509.Certificate, request *x509.CertificateRequest, parent *x509.Certificate, signer crypto.PrivateKey) CertificateFactory
NewRemoteCertificateFactory creates a new certificate factory for request based certificates.
type CertificateRequestFactory ¶
type CertificateRequestFactory interface { // Name returns the name of this factory. Name() string // New creates a new X.509 certificate request. New() (crypto.PrivateKey, *x509.CertificateRequest, error) }
CertificateRequestFactory interface provides a unified way to create X.509 certificate requests.
func NewRemoteCertificateRequestFactory ¶
func NewRemoteCertificateRequestFactory(template *x509.CertificateRequest, keyPairFactory keys.KeyPairFactory) CertificateRequestFactory
NewRemoteCertificateRequestFactory creates a new certificate request factory for remotely signed certificates.
type RevocationListFactory ¶
type RevocationListFactory interface { // Name returns the name of this factory. Name() string // New creates a new X.509 revocation list. New(issuer *x509.Certificate, signer crypto.PrivateKey) (*x509.RevocationList, error) }
RevocationListFactory interface provides a unified way to create X.509 revocation lists.
func NewLocalRevocationListFactory ¶
func NewLocalRevocationListFactory(template *x509.RevocationList) RevocationListFactory
NewLocalRevocationListFactory creates a new revocation list factory for locally issued certificates.