Skip to content

Instantly share code, notes, and snippets.

@kbaribeau
Created July 16, 2012 16:07
Show Gist options
  • Save kbaribeau/3123533 to your computer and use it in GitHub Desktop.
Save kbaribeau/3123533 to your computer and use it in GitHub Desktop.
using custom ssl certs on osx
#see http://jjinux.blogspot.com/2012/02/ruby-working-around-ssl-errors-on-os-x.html
require 'open-uri'
require 'net/https'
module Net
class HTTP
alias_method :original_use_ssl=, :use_ssl=
def use_ssl=(flag)
# Ubuntu
if File.exists?('/etc/ssl/certs')
self.ca_path = '/etc/ssl/certs'
# MacPorts on OS X
# You'll need to run: sudo port install curl-ca-bundle
elsif File.exists?('/opt/local/share/curl/curl-ca-bundle.crt')
self.ca_file = '/opt/local/share/curl/curl-ca-bundle.crt'
end
self.verify_mode = OpenSSL::SSL::VERIFY_PEER
self.original_use_ssl = flag
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment