Class: Verifalia::Security::CertificateAuthenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/verifalia/security/certificate_authenticator.rb

Overview

Allows to authenticate to Verifalia with a client certificate.

Instance Method Summary collapse

Constructor Details

#initialize(ssl_client_cert, ssl_client_key) ⇒ CertificateAuthenticator

Returns a new instance of CertificateAuthenticator.



36
37
38
39
40
41
42
# File 'lib/verifalia/security/certificate_authenticator.rb', line 36

def initialize(ssl_client_cert, ssl_client_key)
  ssl_client_cert = OpenSSL::X509::Certificate.new(File.read(ssl_client_cert)) if ssl_client_cert.is_a?(String)
  ssl_client_key = OpenSSL::PKey::RSA.new(File.read(ssl_client_key)) if ssl_client_key.is_a?(String) && !ssl_client_key.nil?

  @ssl_client_cert = ssl_client_cert
  @ssl_client_key = ssl_client_key
end

Instance Method Details

#authenticate(connection, request) ⇒ Object



44
45
46
47
# File 'lib/verifalia/security/certificate_authenticator.rb', line 44

def authenticate(connection, request)
  connection.ssl.client_cert = @ssl_client_cert
  connection.ssl.client_key = @ssl_client_key
end