class

Beryl::Certificates::NameConstraintCheck

Inherits Reference < Object

Applies one CA's name constraints (RFC 5280 ยง4.2.1.10) to the names of a certificate below it.

  • dNSName: a constraint example.com covers that name and every name ending in .example.com; an empty constraint covers every name. A constraint with a wildcard or a leading period is malformed. A presented wildcard *.base is inside a permitted subtree only when all of it is (base within the subtree), and hits an excluded subtree when any name it could match would (base within the subtree, or the subtree within *.base), which closes CVE-2025-61727.
  • iPAddress: address and mask of 8 or 16 bytes, the mask contiguous.
  • rfc822Name: a mailbox (user@host, the local part compared exactly), a host (host, every mailbox there) or a domain (.domain, every mailbox at a host below it); an asterisk is a literal character.
  • uniformResourceIdentifier: the URI's host against host or .domain.
  • directoryName: the subject name, and directory names in the subject alternative names, must begin with the constraint's relative names.

Email addresses in the subject's emailAddress attributes count as rfc822Name. A constraint of a kind Beryl does not process (otherName, x400Address, ediPartyName, registeredID) refuses any certificate that carries a name of that kind, and is harmless otherwise.

Every comparison is counted against a budget shared by the whole validation, so a certificate with thousands of names under thousands of constraints is refused instead of taking quadratic time.

Constructors

new(largest_comparison_count : Int64)
Source

Class methods

malformed_reason(constraints : NameConstraints) : String | Nil

Returns why constraints are malformed, or nil when they are well formed.

Source

Instance methods

comparison_count
Source
violation(constraints : NameConstraints, certificate : Certificate) : String | Nil

Returns why certificate's names break constraints, or nil when every name is allowed. constraints must be well formed.

Source

Nested types