Class: R509::Cert::Extensions::CertificatePolicies

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

Overview

RFC 5280 Description (see: www.ietf.org/rfc/rfc5280.txt)

The certificate policies extension contains a sequence of one or more policy information terms, each of which consists of an object identifier (OID) and optional qualifiers. Optional qualifiers, which MAY be present, are not expected to change the definition of the policy. A certificate policy OID MUST NOT appear more than once in a certificate policies extension.

You can use this extension to parse an existing extension for easy access to the contents or create a new one.

Constant Summary collapse

OID =

friendly name for CP OID

"certificatePolicies"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg) ⇒ CertificatePolicies

This method takes a hash or an existing Extension object to parse. The hash must contain a :value that is an array of policy information. See the example.

Examples:

R509::Cert::Extensions::CertificatePolicies.new(:value => [
  { :policy_identifier => "2.16.840.1.12345.1.2.3.4.1",
    :cps_uris => ["http://example.com/cps","http://other.com/cps"],
    :user_notices => [ {:explicit_text => "thing", :organization => "my org", :notice_numbers => [1,2,3,4]} ]
 }
])

Parameters:

  • arg (Hash)

    a customizable set of options

Options Hash (arg):

  • :value (Array)

    Array of hashes in the format shown in the examples. This is a complex hash.

  • :critical (Boolean) — default: false


36
37
38
39
40
41
42
43
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 36

def initialize(arg)
  unless R509::Cert::Extensions.is_extension?(arg)
    arg = build_extension(arg)
  end

  super(arg)
  parse_extension
end

Instance Attribute Details

#policiesArray (readonly)

Returns Array of R509::Cert::Extensions::PolicyObjects::PolicyInformation objects.

Returns:

  • (Array)

    Array of R509::Cert::Extensions::PolicyObjects::PolicyInformation objects



22
23
24
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 22

def policies
  @policies
end

Instance Method Details

#to_hHash

Returns:

  • (Hash)


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

def to_h
  {
    :critical => self.critical?,
    :value => @policies.map { |policy| policy.to_h }
  }
end

#to_yamlYAML

Returns:

  • (YAML)


54
55
56
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 54

def to_yaml
  self.to_h.to_yaml
end