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

OID =

friendly name for CP OID

"certificatePolicies"

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (CertificatePolicies) initialize(arg)

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


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

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

  super(arg)
  parse_extension
end

Instance Attribute Details

- (Array) policies (readonly)

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

Returns:

  • (Array)

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



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

def policies
  @policies
end

Instance Method Details

- (Hash) to_h

Returns:

  • (Hash)


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

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

- (YAML) to_yaml

Returns:

  • (YAML)


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

def to_yaml
  self.to_h.to_yaml
end