Class: R509::OCSP::Response
- Inherits:
-
Object
- Object
- R509::OCSP::Response
- Defined in:
- lib/r509/ocsp.rb
Overview
builds OCSP responses
Class Method Summary collapse
Instance Method Summary collapse
- #basic ⇒ OpenSSL::OCSP::BasicResponse
-
#check_nonce(ocsp_request) ⇒ R509::OCSP::Request::Nonce::CONSTANT
The status code of the nonce check.
-
#initialize(ocsp_response) ⇒ Response
constructor
A new instance of Response.
-
#status ⇒ OpenSSL::OCSP
Response status of this response.
-
#to_der ⇒ String
Der encoded string.
-
#verify(certs) ⇒ Boolean
True if the response is valid according to the given root.
Constructor Details
#initialize(ocsp_response) ⇒ Response
Returns a new instance of Response
10 11 12 13 14 15 |
# File 'lib/r509/ocsp.rb', line 10 def initialize(ocsp_response) unless ocsp_response.is_a?(OpenSSL::OCSP::Response) raise R509::R509Error, 'You must pass an OpenSSL::OCSP::Response object to the constructor. See R509::OCSP::Response.parse if you are trying to parse' end @ocsp_response = ocsp_response end |
Class Method Details
.parse(ocsp_string) ⇒ R509::OCSP::Response
18 19 20 21 22 23 |
# File 'lib/r509/ocsp.rb', line 18 def self.parse(ocsp_string) if ocsp_string.nil? raise R509::R509Error, 'You must pass a DER encoded OCSP response to this method' end R509::OCSP::Response.new(OpenSSL::OCSP::Response.new(ocsp_string)) end |
Instance Method Details
#basic ⇒ OpenSSL::OCSP::BasicResponse
36 37 38 |
# File 'lib/r509/ocsp.rb', line 36 def basic @ocsp_response.basic end |
#check_nonce(ocsp_request) ⇒ R509::OCSP::Request::Nonce::CONSTANT
Returns the status code of the nonce check
66 67 68 |
# File 'lib/r509/ocsp.rb', line 66 def check_nonce(ocsp_request) ocsp_request.check_nonce(@ocsp_response.basic) end |
#status ⇒ OpenSSL::OCSP
Returns response status of this response
26 27 28 |
# File 'lib/r509/ocsp.rb', line 26 def status @ocsp_response.status end |
#to_der ⇒ String
Returns der encoded string
31 32 33 |
# File 'lib/r509/ocsp.rb', line 31 def to_der @ocsp_response.to_der end |
#verify(certs) ⇒ Boolean
Returns true if the response is valid according to the given root
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/r509/ocsp.rb', line 42 def verify(certs) store = OpenSSL::X509::Store.new if certs.is_a?(Array) stack = certs certs.each do |cert| store.add_cert(cert) end else stack = [certs] store.add_cert(certs) end # suppress verbosity since #verify will output a warning if it does not match # as well as returning false. we just want the boolean original_verbosity = $VERBOSE $VERBOSE = nil # still a bit unclear on why we add to store and pass in array to verify result = @ocsp_response.basic.verify(stack, store) $VERBOSE = original_verbosity result end |