Class: SCEP::PKIOperation::Response
- Defined in:
- lib/scep/pki_operation/response.rb
Overview
Represents a SCEP response from the PKIOperation, which can do two of the following:
- Parse a response form another SCEP server (useful for proxying)
- Create our own SCEP response
Constant Summary
Constants inherited from Base
Base::DEFAULT_CIPHER_ALGORITHM
Instance Attribute Summary
Attributes inherited from Base
#p7enc, #p7sign, #ra_keypair, #x509_store
Instance Method Summary collapse
-
#decrypt(raw_string, verify = true) ⇒ Array<OpenSSL::X509::Certificates>
Decrypts a raw response and assigns #signed_certificates.
-
#encrypt(target_encryption_certs) ⇒ String
Takes the #signed_certificates attached to this object and return them in a format defined by SCEP.
-
#proxy(signed_and_encrypted_certs, target_encryption_certs, verify = true) ⇒ OpenSSL::PKCS7
Decrypts a signed and encrypted response, gets the certificates (#signed_certificates) and then re-encrypts and signs it.
-
#signed_certificates ⇒ Array<OpenSSL::X509::Certificate>
Gets any signed certificates that will be encrypted and signed in a SCEP format.
-
#signed_certificates=(certs) ⇒ Object
Adds a single, or many certificates to encrypt and sign further.
Methods inherited from Base
#add_verification_certificate, #check_if_recipient_matches_ra_certificate_name, create_default_cipher, #initialize, #sign_and_encrypt_raw, #unsign_and_unencrypt_raw, #wrap_array
Methods included from Loggable
Constructor Details
This class inherits a constructor from SCEP::PKIOperation::Base
Instance Method Details
#decrypt(raw_string, verify = true) ⇒ Array<OpenSSL::X509::Certificates>
Decrypts a raw response and assigns #signed_certificates
56 57 58 59 60 |
# File 'lib/scep/pki_operation/response.rb', line 56 def decrypt(raw_string, verify = true) p7raw = unsign_and_unencrypt_raw(raw_string, verify) p7certs = OpenSSL::PKCS7.new(p7raw) @signed_certificates = p7certs.certificates end |
#encrypt(target_encryption_certs) ⇒ String
Takes the #signed_certificates attached to this object and return them in a format defined by SCEP.
68 69 70 71 72 73 |
# File 'lib/scep/pki_operation/response.rb', line 68 def encrypt(target_encryption_certs) raise ArgumentError, 'Must contain at least one of #signed_certificates' unless signed_certificates.any? p7certs = PKCS7CertOnly.new(signed_certificates) sign_and_encrypt_raw(p7certs.to_der, target_encryption_certs) end |
#proxy(signed_and_encrypted_certs, target_encryption_certs, verify = true) ⇒ OpenSSL::PKCS7
Decrypts a signed and encrypted response, gets the certificates (#signed_certificates) and then re-encrypts and signs it.
80 81 82 83 |
# File 'lib/scep/pki_operation/response.rb', line 80 def proxy(signed_and_encrypted_certs, target_encryption_certs, verify = true) decrypt(signed_and_encrypted_certs, verify) encrypt(target_encryption_certs) end |
#signed_certificates ⇒ Array<OpenSSL::X509::Certificate>
Gets any signed certificates that will be encrypted and signed in a SCEP format
48 49 50 |
# File 'lib/scep/pki_operation/response.rb', line 48 def signed_certificates @signed_certificates ||= [] end |
#signed_certificates=(certs) ⇒ Object
Adds a single, or many certificates to encrypt and sign further
42 43 44 |
# File 'lib/scep/pki_operation/response.rb', line 42 def signed_certificates=(certs) @signed_certificates = wrap_array(certs) end |