class TTTLS13::Message::Extension::OCSPResponse

Attributes

extension_type[R]
ocsp_response[R]

Public Class Methods

deserialize(binary) click to toggle source

@param binary [String]

@raise [TTTLS13::Error::ErrorAlerts]

@return [TTTLS13::Message::Extension::OCSPResponse, nil]

# File lib/tttls1.3/message/extension/status_request.rb, line 142
def self.deserialize(binary)
  raise Error::ErrorAlerts, :internal_error if binary.nil?
  return nil if binary.length < 4 ||
                binary[0] != CertificateStatusType::OCSP

  res_len = Convert.bin2i(binary.slice(1, 3))
  res = binary.slice(4, res_len)
  ocsp_response = nil
  begin
    ocsp_response = OpenSSL::OCSP::Response.new(res)
  rescue OpenSSL::OCSP::OCSPError
    return nil
  end
  return nil if 4 + res_len != binary.length

  OCSPResponse.new(ocsp_response)
end
new(ocsp_response) click to toggle source

@param ocsp_response [OpenSSL::OCSP::Response]

@example

OCSPResponse.new(
  OpenSSL::OCSP::Response.create(status, basic_resp)
)
# File lib/tttls1.3/message/extension/status_request.rb, line 123
def initialize(ocsp_response)
  @extension_type = ExtensionType::STATUS_REQUEST
  @ocsp_response = ocsp_response
end

Public Instance Methods

serialize() click to toggle source

@return [String]

# File lib/tttls1.3/message/extension/status_request.rb, line 129
def serialize
  binary = ''
  binary += CertificateStatusType::OCSP
  binary += @ocsp_response.to_der.prefix_uint24_length

  @extension_type + binary.prefix_uint16_length
end