Class: R509::Cert::Extensions::BasicConstraints

Inherits:
OpenSSL::X509::Extension
  • Object
show all
Defined in:
lib/r509/cert/extensions.rb

Overview

Implements the BasicConstraints certificate extension, with methods to provide access to the components and meaning of the extension's contents.

Constant Summary

OID =
"basicConstraints"

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (BasicConstraints) initialize(*args)

See OpenSSL::X509::Extension#initialize



34
35
36
37
38
39
40
# File 'lib/r509/cert/extensions.rb', line 34

def initialize(*args)
  super(*args)

  @is_ca = ! ( self.value =~ /CA:TRUE/ ).nil?
  pathlen_match = self.value.match( /pathlen:(\d+)/ )
  @path_length = pathlen_match[1].to_i unless pathlen_match.nil?
end

Instance Attribute Details

- (Object) path_length (readonly)

Returns the value of attribute path_length



31
32
33
# File 'lib/r509/cert/extensions.rb', line 31

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 sign CA certificates.

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/r509/cert/extensions.rb', line 48

def allows_sub_ca?()
  return false if @path_length.nil?
  return @path_length > 0
end

- (Boolean) is_ca?

Returns:

  • (Boolean)


42
43
44
# File 'lib/r509/cert/extensions.rb', line 42

def is_ca?()
  return @is_ca == true
end