Permalink
Browse files

Adds class method for setting PKCS12 certificate

  • Loading branch information...
1 parent a1b52f2 commit 8afab49443d341f6dcbcbcc92214c980c2524a2a @gareth gareth committed Oct 22, 2013
Showing with 23 additions and 0 deletions.
  1. +11 −0 lib/httparty.rb
  2. +12 −0 spec/httparty_spec.rb
View
@@ -282,6 +282,17 @@ def pem(pem_contents, password=nil)
default_options[:pem_password] = password
end
+ # Allows setting a PKCS12 file to be used
+ #
+ # class Foo
+ # include HTTParty
+ # pkcs12 File.read('/home/user/my.p12'), "password"
+ # end
+ def pkcs12(p12_contents, password)
+ default_options[:p12] = p12_contents
+ default_options[:p12_password] = password
+ end
+
# Override the way query strings are normalized.
# Helpful for overriding the default rails normalization of Array queries.
#
View
@@ -38,6 +38,18 @@
end
end
+ describe "pkcs12" do
+ it 'should set the p12 content' do
+ @klass.pkcs12 'P12-CONTENT', 'PASSWORD'
+ @klass.default_options[:p12].should == 'P12-CONTENT'
+ end
+
+ it 'should set the password' do
+ @klass.pkcs12 'P12-CONTENT', 'PASSWORD'
+ @klass.default_options[:p12_password].should == 'PASSWORD'
+ end
+ end
+
describe 'ssl_version' do
it 'should set the ssl_version content' do
@klass.ssl_version :SSLv3

0 comments on commit 8afab49

Please sign in to comment.