Permalink
Browse files

Allow specifying a CA certificate

git-svn-id: svn://78.47.249.61/ruby-mediawiki/trunk@78 ba9c31aa-a806-0410-9a81-9f13d15ee83b
  • Loading branch information...
neingeist
neingeist committed Apr 16, 2010
1 parent 2f76cdd commit 813a3dd505ab2926334dd6a008e283205afdcdd6
Showing with 9 additions and 2 deletions.
  1. +9 −2 lib/mediawiki/minibrowser.rb
@@ -34,10 +34,17 @@ class MiniBrowser
##
# Initialize a MiniBrowser instance
# url:: [URI::HTTP] or [URI::HTTPS]
- def initialize(url)
+ # ca_file:: [String] Path to a CA certificate file
+ def initialize(url, ca_file = "/etc/ssl/certs/ca-certificates.crt")
@url = url
@http = Net::HTTP.new( @url.host, @url.port )
- @http.use_ssl = true if @url.class == URI::HTTPS
+ if @url.class == URI::HTTPS
+ @http.use_ssl = true
+ if File.exist?(ca_file)
+ @http.verify_mode = OpenSSL::SSL::VERIFY_PEER
+ @http.ca_file = ca_file
+ end
+ end
@user_agent = 'WikiBot'
@cookies = {}
end

0 comments on commit 813a3dd

Please sign in to comment.