Class: R509::Cert::Extensions::NameConstraints
- Inherits:
-
OpenSSL::X509::Extension
- Object
- OpenSSL::X509::Extension
- R509::Cert::Extensions::NameConstraints
- Defined in:
- lib/r509/cert/extensions/name_constraints.rb
Overview
RFC 5280 Description (see: www.ietf.org/rfc/rfc5280.txt)
The name constraints extension, which MUST be used only in a CA certificate, indicates a name space within which all subject names in subsequent certificates in a certification path MUST be located. Restrictions apply to the subject distinguished name and apply to subject alternative names. Restrictions apply only when the specified name form is present. If no name of the type is in the certificate, the certificate is acceptable.
Name constraints are not applied to self-issued certificates (unless the certificate is the final certificate in the path). (This could prevent CAs that use name constraints from employing self-issued certificates to implement key rollover.)
Restrictions are defined in terms of permitted or excluded name subtrees. Any name matching a restriction in the excludedSubtrees field is invalid regardless of information appearing in the permittedSubtrees. Conforming CAs MUST mark this extension as critical and SHOULD NOT impose name constraints on the x400Address, ediPartyName, or registeredID name forms. Conforming CAs MUST NOT issue certificates where name constraints is an empty sequence. That is, either the permittedSubtrees field or the excludedSubtrees MUST be present.
You can use this extension to parse an existing extension for easy access to the contents or create a new one.
Constant Summary
- OID =
friendly name for CP OID
"nameConstraints"
Instance Attribute Summary (collapse)
Instance Method Summary (collapse)
-
- (NameConstraints) initialize(arg)
constructor
A new instance of NameConstraints.
- - (Hash) to_h
- - (YAML) to_yaml
Constructor Details
- (NameConstraints) initialize(arg)
When supplying IP you must supply a full netmask in addition to an IP. (both IPv4 and IPv6 supported)
When supplying dirName the value is an R509::Subject or the hash used to build an R509::Subject
A new instance of NameConstraints
65 66 67 68 69 70 71 72 |
# File 'lib/r509/cert/extensions/name_constraints.rb', line 65 def initialize(arg) if not R509::Cert::Extensions.is_extension?(arg) arg = build_extension(arg) end super(arg) parse_extension end |
Instance Attribute Details
- (R509::ASN1::GeneralNames?) excluded (readonly)
40 41 42 |
# File 'lib/r509/cert/extensions/name_constraints.rb', line 40 def excluded @excluded end |
- (R509::ASN1::GeneralNames?) permitted (readonly)
40 41 42 |
# File 'lib/r509/cert/extensions/name_constraints.rb', line 40 def permitted @permitted end |
Instance Method Details
- (Hash) to_h
75 76 77 78 79 80 |
# File 'lib/r509/cert/extensions/name_constraints.rb', line 75 def to_h hash = { :critical => self.critical? } hash[:permitted] = R509::Cert::Extensions.names_to_h(@permitted.names) unless @permitted.names.empty? hash[:excluded] = R509::Cert::Extensions.names_to_h(@excluded.names) unless @excluded.names.empty? hash end |
- (YAML) to_yaml
83 84 85 |
# File 'lib/r509/cert/extensions/name_constraints.rb', line 83 def to_yaml self.to_h.to_yaml end |