Documentation ¶
Overview ¶
Package certnames contains helpers for validating X.509 client certificates.
Index ¶
- Constants
- type CertNames
- func (cns CertNames) AppendTo(out *strings.Builder)
- func (cns CertNames) Check(cert *x509.Certificate) bool
- func (cns *CertNames) FromList(list []string) error
- func (cns CertNames) IsPermitAll() bool
- func (cns CertNames) List() []string
- func (cns CertNames) MarshalJSON() ([]byte, error)
- func (cns *CertNames) Parse(str string) error
- func (cns CertNames) String() string
- func (cns *CertNames) UnmarshalJSON(raw []byte) error
- type ParseError
Constants ¶
const ANY = "ANY"
ANY is the string representation of a CertNames that permits all certificates.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertNames ¶
type CertNames struct {
// contains filtered or unexported fields
}
CertNames is a set of permitted Subject Distinguished Name and Subject Alternative Name components that a client certificate can match.
func (CertNames) AppendTo ¶
AppendTo efficiently appends the string representation to the given Builder. See FromList for details about the format.
func (CertNames) Check ¶
func (cns CertNames) Check(cert *x509.Certificate) bool
Check returns true if the given cert matches at least one permitted name.
func (*CertNames) FromList ¶
FromList parses a list of names.
"ANY" permits all certificates
"O=<org>" permits certs with a Subject.Organization of <org>
"OU=<unit>" permits certs with a Subject.OrganizationalUnit of <unit>
"CN=<name>" permits certs with a Subject.CommonName of <name>
"E=<email>" permits certs with a Subject.Name of Type OID(1.2.840.113549.1.9.1) (the obsolete DN field "emailAddress") and value <email>, or with an EmailAddress SAN of <email>
If the list item isn't "KEY=VALUE"-shaped, then the parser will make an educated guess as to whether the list item is meant to be a commonName or an emailAddress.
func (CertNames) IsPermitAll ¶
IsPermitAll returns true if all certificates are permitted.
func (CertNames) List ¶
List returns the list of permitted names, or ["ANY"] if all certificates are permitted. See FromList for details about the format.
func (CertNames) MarshalJSON ¶
MarshalJSON fulfills json.Marshaler.
func (*CertNames) Parse ¶
Parse parses a colon-delimited list of names. See FromList for details about the format.
func (CertNames) String ¶
String returns a colon-delimited list of permitted names, or "ANY" if all certificates are permitted. See FromList for details about the format.
func (*CertNames) UnmarshalJSON ¶
UnmarshalJSON fulfills json.Unmarshaler.
type ParseError ¶
ParseError represents a parsing error in CertNames.FromList.