struct

Beryl::Certificates::ServiceIdentity

Inherits Struct < Value < Object

The name a client expects the server to prove: a DNS name or an IP address (RFC 9525's DNS-ID and IP-ID).

identity = Beryl::Certificates::ServiceIdentity.new("www.example.com")
identity.matches?(certificate) # => true when a SAN dNSName matches

Matching follows RFC 9525 §6:

  • a DNS name is compared with the certificate's subject alternative dNSName entries only; the common name is never used (§6.2.1);
  • comparison is case-insensitive over ASCII (§6.3), on A-labels: a name with characters outside ASCII is refused, and the caller converts an internationalized name to its A-label form first;
  • a presented name may start with one wildcard label *, which matches exactly one non-empty label of the reference name (§6.3); a wildcard anywhere else, a partial wildcard such as f*.example.com, and a wildcard covering a whole public suffix (*.com, *.co.uk) do not match;
  • an IP address is compared with the subject alternative iPAddress entries only, byte for byte (§6.2.2).

Constructors

new(reference : String)

Reads reference as an IP address when it is one in textual form (dotted-quad IPv4 or RFC 4291 IPv6), and as a DNS name otherwise. Raises ArgumentError when it is neither.

Source

Instance methods

domain_name

The DNS name in lowercase, without a final dot, or nil for an IP.

Source
ip_address

The 4 or 16 address bytes, or nil for a DNS name.

Source
matches?(certificate : Certificate) : Bool

Returns whether a subject alternative name of certificate matches.

Source
to_s(io : IO) : Nil

Same as #inspect(io).

Source