Documentation
¶
Overview ¶
Package x509 implements a subset of the X.509 standard.
It allows parsing and generating certificates, certificate signing requests, certificate revocation lists, and encoded public and private keys. It provides a certificate verifier, complete with a chain builder.
The package targets the X.509 technical profile defined by the IETF (RFC 2459/3280/5280), and as further restricted by the CA/Browser Forum Baseline Requirements. There is minimal support for features outside of these profiles, as the primary goal of the package is to provide compatibility with the publicly trusted TLS certificate ecosystem and its policies and constraints.
On macOS and Windows, certificate verification is handled by system APIs, but the package aims to apply consistent validation rules across operating systems.
Index ¶
- func ParseCertificates(der []byte) ([]*stdx509.Certificate, error)
- type ExtKeyUsage
- type KeyUsage
- type OID
- func (o OID) AppendBinary(b []byte) ([]byte, error)
- func (o OID) AppendText(b []byte) ([]byte, error)
- func (oid OID) Equal(other OID) bool
- func (oid OID) EqualASN1OID(other asn1.ObjectIdentifier) bool
- func (o OID) MarshalBinary() ([]byte, error)
- func (o OID) MarshalText() ([]byte, error)
- func (oid OID) String() string
- func (o *OID) UnmarshalBinary(b []byte) error
- func (o *OID) UnmarshalText(text []byte) error
- type PublicKeyAlgorithm
- type SignatureAlgorithm
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseCertificates ¶
func ParseCertificates(der []byte) ([]*stdx509.Certificate, error)
ParseCertificates parses one or more certificates from the given ASN.1 DER data. The certificates must be concatenated with no intermediate padding.
Types ¶
type ExtKeyUsage ¶
type ExtKeyUsage int
ExtKeyUsage represents an extended set of actions that are valid for a given key. Each of the ExtKeyUsage* constants define a unique action.
const ( ExtKeyUsageAny ExtKeyUsage = iota ExtKeyUsageServerAuth ExtKeyUsageClientAuth ExtKeyUsageCodeSigning ExtKeyUsageEmailProtection ExtKeyUsageIPSECEndSystem ExtKeyUsageIPSECTunnel ExtKeyUsageIPSECUser ExtKeyUsageTimeStamping ExtKeyUsageOCSPSigning ExtKeyUsageMicrosoftServerGatedCrypto ExtKeyUsageNetscapeServerGatedCrypto ExtKeyUsageMicrosoftCommercialCodeSigning ExtKeyUsageMicrosoftKernelCodeSigning )
type KeyUsage ¶
type KeyUsage int
KeyUsage represents the set of actions that are valid for a given key. It's a bitmap of the KeyUsage* constants.
type OID ¶
type OID struct {
// contains filtered or unexported fields
}
An OID represents an ASN.1 OBJECT IDENTIFIER.
func OIDFromInts ¶
OIDFromInts creates a new OID using ints, each integer is a separate component.
func ParseOID ¶
ParseOID parses a Object Identifier string, represented by ASCII numbers separated by dots.
func (OID) AppendBinary ¶
AppendBinary implements encoding.BinaryAppender
func (OID) AppendText ¶
AppendText implements encoding.TextAppender
func (OID) EqualASN1OID ¶
func (oid OID) EqualASN1OID(other asn1.ObjectIdentifier) bool
EqualASN1OID returns whether an OID equals an asn1.ObjectIdentifier. If asn1.ObjectIdentifier cannot represent the OID specified by oid, because a component of OID requires more than 31 bits, it returns false.
func (OID) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler
func (OID) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (*OID) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler
func (*OID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler
type PublicKeyAlgorithm ¶
type PublicKeyAlgorithm int
const ( UnknownPublicKeyAlgorithm PublicKeyAlgorithm = iota RSA DSA // Only supported for parsing. ECDSA Ed25519 )
func (PublicKeyAlgorithm) String ¶
func (algo PublicKeyAlgorithm) String() string
type SignatureAlgorithm ¶
type SignatureAlgorithm int
const ( UnknownSignatureAlgorithm SignatureAlgorithm = iota MD2WithRSA // Unsupported. MD5WithRSA // Only supported for signing, not verification. SHA1WithRSA // Only supported for signing, and verification of CRLs, CSRs, and OCSP responses. SHA256WithRSA SHA384WithRSA SHA512WithRSA DSAWithSHA1 // Unsupported. DSAWithSHA256 // Unsupported. ECDSAWithSHA1 // Only supported for signing, and verification of CRLs, CSRs, and OCSP responses. ECDSAWithSHA256 ECDSAWithSHA384 ECDSAWithSHA512 SHA256WithRSAPSS SHA384WithRSAPSS SHA512WithRSAPSS PureEd25519 )
func (SignatureAlgorithm) String ¶
func (algo SignatureAlgorithm) String() string