Module: Google::APIClient::PKCS12
- Defined in:
- lib/google/api_client/service_account.rb
Overview
Helper for loading keys from the PKCS12 files downloaded when setting up service accounts at the APIs Console.
Class Method Summary collapse
-
.load_key(keyfile, passphrase) ⇒ OpenSSL::PKey
Loads a key from PKCS12 file, assuming a single private key is present.
Class Method Details
.load_key(keyfile, passphrase) ⇒ OpenSSL::PKey
Loads a key from PKCS12 file, assuming a single private key is present.
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/google/api_client/service_account.rb', line 36 def self.load_key(keyfile, passphrase) begin if File.exists?(keyfile) content = File.read(keyfile) else content = keyfile end pkcs12 = OpenSSL::PKCS12.new(content, passphrase) return pkcs12.key rescue OpenSSL::PKCS12::PKCS12Error raise ArgumentError.new("Invalid keyfile or passphrase") end end |