summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormo <mo@mokhan.ca>2018-05-07 14:55:40 -0600
committermo <mo@mokhan.ca>2018-05-07 14:55:40 -0600
commit8fa9c4e921b87c6d7b3b8d34a4506653ad5117c9 (patch)
tree6c8841d23808e0d27f89c10492192915ea41893d /lib
parent9014e187ce3591a3faf1075efac830893f023e0d (diff)
support a passphrase.v0.1.0
Diffstat (limited to 'lib')
-rw-r--r--lib/net/hippie/client.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/net/hippie/client.rb b/lib/net/hippie/client.rb
index dd1f228..b43e036 100644
--- a/lib/net/hippie/client.rb
+++ b/lib/net/hippie/client.rb
@@ -7,7 +7,13 @@ module Net
'User-Agent' => "net/hippie #{Net::Hippie::VERSION}",
}
- def initialize(headers: DEFAULT_HEADERS, certificate: nil, key: nil, mapper: JsonMapper.new)
+ def initialize(
+ headers: DEFAULT_HEADERS,
+ certificate: nil,
+ key: nil,
+ passphrase: nil,
+ mapper: JsonMapper.new
+ )
@certificate = certificate
@default_headers = headers
@key = key
@@ -50,7 +56,8 @@ module Net
private
- attr_reader :default_headers, :certificate, :key
+ attr_reader :default_headers
+ attr_reader :certificate, :key, :passphrase
attr_reader :mapper
def http_for(uri)
@@ -59,7 +66,13 @@ module Net
http.use_ssl = uri.is_a?(URI::HTTPS)
http.set_debug_output(Net::Hippie.logger)
http.cert = OpenSSL::X509::Certificate.new(certificate) if certificate
- http.key = OpenSSL::PKey::RSA.new(key) if key
+ if key
+ if passphrase
+ http.key = OpenSSL::PKey::RSA.new(key, passphrase)
+ else
+ http.key = OpenSSL::PKey::RSA.new(key)
+ end
+ end
http
end