Class: NubankSdk::Certificate

Inherits:
Object
  • Object
show all
Defined in:
lib/nubank_sdk/certificate.rb

Overview

Controller of certifications

Constant Summary collapse

FILES_PATH =
'./certificates/'

Instance Method Summary collapse

Constructor Details

#initialize(cpf) ⇒ Certificate

Controller of certifications

Parameters:

  • cpf (String)


16
17
18
# File 'lib/nubank_sdk/certificate.rb', line 16

def initialize(cpf)
  @cpf = cpf
end

Instance Method Details

#encodedOpenSSL::PKCS12

Load the certificate file

Returns:

  • (OpenSSL::PKCS12)


38
39
40
# File 'lib/nubank_sdk/certificate.rb', line 38

def encoded
  @encoded ||= OpenSSL::PKCS12.new(file.read, 'password')
end

#process_decoded(key, certificate) ⇒ File

Create a certificate file

Parameters:

  • key (OpenSSL::PKey::RSA)
  • certificate (String)

Returns:

  • (File)


27
28
29
30
31
32
# File 'lib/nubank_sdk/certificate.rb', line 27

def process_decoded(key, certificate)
  encoded = encode certificate

  p12 = create_pkcs12_from(key, encoded)
  save p12
end