Class: R509::Cert::Extensions::BasicConstraints
- Inherits:
-
OpenSSL::X509::Extension
- Object
- OpenSSL::X509::Extension
- R509::Cert::Extensions::BasicConstraints
- Defined in:
- lib/r509/cert/extensions/basic_constraints.rb
Overview
RFC 5280 Description (see: www.ietf.org/rfc/rfc5280.txt)
The basic constraints extension identifies whether the subject of the certificate is a CA and the maximum depth of valid certification paths that include this certificate.
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 BasicConstraints OID
"basicConstraints"
Instance Attribute Summary (collapse)
-
- (Integer?) path_length
readonly
returns the path length (if present).
Instance Method Summary (collapse)
-
- (Boolean) allows_sub_ca?
Returns true if the path length allows this certificate to be used to create subordinate signing certificates beneath it.
-
- (BasicConstraints) initialize(arg)
constructor
This method takes a hash or an existing Extension object to parse.
-
- (Boolean) is_ca?
Check whether the extension value would make the parent certificate a CA.
- - (Hash) to_h
- - (YAML) to_yaml
Constructor Details
- (BasicConstraints) initialize(arg)
This method takes a hash or an existing Extension object to parse
28 29 30 31 32 33 34 35 |
# File 'lib/r509/cert/extensions/basic_constraints.rb', line 28 def initialize(arg) if not R509::Cert::Extensions.is_extension?(arg) arg = build_extension(arg) end super(arg) parse_extension end |
Instance Attribute Details
- (Integer?) path_length (readonly)
returns the path length (if present)
22 23 24 |
# File 'lib/r509/cert/extensions/basic_constraints.rb', line 22 def path_length @path_length end |
Instance Method Details
- (Boolean) allows_sub_ca?
Returns true if the path length allows this certificate to be used to create subordinate signing certificates beneath it. Does not check if there is a pathlen restriction in the cert chain above the current cert
47 48 49 50 51 |
# File 'lib/r509/cert/extensions/basic_constraints.rb', line 47 def allows_sub_ca? return false unless is_ca? return true if @path_length.nil? return @path_length > 0 end |
- (Boolean) is_ca?
Check whether the extension value would make the parent certificate a CA
39 40 41 |
# File 'lib/r509/cert/extensions/basic_constraints.rb', line 39 def is_ca? return @is_ca == true end |
- (Hash) to_h
54 55 56 57 58 |
# File 'lib/r509/cert/extensions/basic_constraints.rb', line 54 def to_h hash = { :ca => @is_ca, :critical => self.critical? } hash[:path_length] = @path_length unless @path_length.nil? or not is_ca? hash end |
- (YAML) to_yaml
61 62 63 |
# File 'lib/r509/cert/extensions/basic_constraints.rb', line 61 def to_yaml self.to_h.to_yaml end |