Class: R509::CertificateAuthority::OptionsBuilder
- Inherits:
-
Object
- Object
- R509::CertificateAuthority::OptionsBuilder
- Defined in:
- lib/r509/certificate_authority/options_builder.rb
Overview
A class to build hashes to send to the R509::CertificateAuthority::Signer. These are built from R509::Config::CertProfile objects and additional data supplied to the #build_and_enforce method.
Instance Method Summary (collapse)
-
- (Hash) build_and_enforce(options)
Hash of :message_digest, :subject, :extensions, and :csr/:spki ready to be passed to the Signer.
-
- (OptionsBuilder) initialize(config)
constructor
A new instance of OptionsBuilder.
Constructor Details
- (OptionsBuilder) initialize(config)
A new instance of OptionsBuilder
4 5 6 7 8 9 |
# File 'lib/r509/certificate_authority/options_builder.rb', line 4 def initialize(config) if not config.kind_of?(R509::Config::CAConfig) raise ArgumentError, "You must supply a R509::Config::CAConfig object to this class at instantiation" end @config = config end |
Instance Method Details
- (Hash) build_and_enforce(options)
Hash of :message_digest, :subject, :extensions, and :csr/:spki ready to be passed to the Signer
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/r509/certificate_authority/options_builder.rb', line 20 def build_and_enforce() profile = @config.profile([:profile_name]) R509::CertificateAuthority::Signer.() if (.has_key?(:csr) and not [:csr].verify_signature) or (.has_key?(:spki) and not [:spki].verify_signature) raise R509::R509Error, "Request signature is invalid." end raw_subject, public_key = R509::CertificateAuthority::Signer.extract_public_key_subject() = enforce_md([:message_digest],profile) subject = enforce_subject_item_policy(raw_subject,profile) enforce_not_after([:not_after]) extensions = build_and_merge_extensions(, profile, public_key) build_hash(subject, extensions, , ) end |