Documentation ¶
Overview ¶
Package skid provides type SKID, along with supporting functions and methods. SKID is a byte slice representing an x509 Subject Key Identifier as defined by RFC-5280 Section 4.2.1.2.
SKID values constructed by this package are compatible with those generated by openssl or the standard library's crtpto/x509 package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoCertificate = errors.New("nil cert") ErrNoCSR = errors.New("nil csr") )
Functions ¶
This section is empty.
Types ¶
type SKID ¶
type SKID []byte
SKID is a byte slice representing an x509 Subject Key Identifier per RFC-5280 Section 4.2.1.2.
func FromCSR ¶
func FromCSR(csr *x509.CertificateRequest) (SKID, error)
FromCSR returns a SKID constructed using the public key contained within the given certificate request. If csr is nil, then FromCSR returns a nil SKID and ErrNoCSR.
func FromCertificate ¶
func FromCertificate(cert *x509.Certificate) (SKID, error)
FromCertificate returns a SKID from the given certificate. If cert is nil then FromCertificate returns a nil skid and ErrNoCertificate. If the given certificate has no Subject Key Identifier, one will be generated from its Public Key (if possible) by calling FromPublicKey.
func FromPublicKey ¶
FromPublicKey returns a SKID constructed from the given public key or nil and an error if pub is of an unsupported type.
Currently supported key types are the same as for the standard library's x509.CreateCertificate function -- namely: *rsa.PublicKey, *ecdsa.PublicKey, and *ed25519.PublicKey.
Additionally, FromPublicKey may also return an error if pub is of type *rsa.PublicKey and fails to encode as ASN.1.
func FromString ¶
FromString returns a SKID value parsed from the given string -- which should be a colon-separated, hexadecimal representattion (as generated by SKID's String method). If s is the empty string then FromString will return a nil SKID and no error. FromString will return a non-nil error if any of its elements fails to parse as a hexadecimal value.