Permalink
Browse files

- skip SSL certificate validation on JRuby 1.9 when SSL_CERT_DIR is n…

…ot set
  • Loading branch information...
1 parent 945da34 commit 1c9b834161dc2a2a4ee722ad223014015e039500 @dsander dsander committed Apr 12, 2012
Showing with 14 additions and 3 deletions.
  1. +4 −2 README.md
  2. +5 −0 lib/profitbricks/profitbricks.rb
  3. +5 −1 spec/spec_helper.rb
View
@@ -8,9 +8,11 @@
A Ruby client for the ProfitBricks API.
## Dependencies
-A Ruby interpreter (MRI 1.8.7, 1.9.2, 1.9.3 and JRuby 1.8 passing the tests).
-Examples work on Rubinius, but the tests do not pass.
+A Ruby interpreter (MRI 1.8.7/1.9.2/1.9.3, JRuby 1.8/1.9 and Rubinius 1.8/1.9).
+To get the SSL certificate verification on JRuby 1.9 to work (at least on ubuntu/debian) export the following environment variable:
+
+ export SSL_CERT_DIR=/etc/ssl/certs
## Installation
gem install profitbricks
@@ -11,12 +11,17 @@ def self.configure(&block)
Savon.configure do |config|
config.raise_errors = false
config.log = Profitbricks::Config.log
+
end
HTTPI.log = false
@client = Savon::Client.new do |wsdl, http|
wsdl.endpoint = "https://api.profitbricks.com/1.1"
wsdl.document = "https://api.profitbricks.com/1.1/wsdl"
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && !ENV['SSL_CERT_DIR']
+ puts "Warning: SSL certificate verification has been disabled"
+ http.auth.ssl.verify_mode = :none
+ end
http.auth.basic Profitbricks::Config.username, Profitbricks::Config.password
end
View
@@ -33,9 +33,13 @@
config.log_level = :error
end
HTTPI.log = false
-client = Savon::Client.new do
+client = Savon::Client.new do |wsdl, http|
wsdl.endpoint = "https://api.profitbricks.com/1.1"
wsdl.document = "https://api.profitbricks.com/1.1/wsdl"
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && !ENV['SSL_CERT_DIR']
+ puts "Warning: SSL certificate verification has been disabled"
+ http.auth.ssl.verify_mode = :none
+ end
end
Profitbricks.configure do |config|

0 comments on commit 1c9b834

Please sign in to comment.