Created
March 18, 2012 16:31
-
-
Save pkrnjevic/2076910 to your computer and use it in GitHub Desktop.
One line fix for ruby 1.9.3 net/http to find ca-bundle.crt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Turn on/off SSL. | |
# This flag must be set before starting session. | |
# If you change use_ssl value after session started, | |
# a Net::HTTP object raises IOError. | |
def use_ssl=(flag) | |
flag = flag ? true : false | |
if started? and @use_ssl != flag | |
raise IOError, "use_ssl value changed, but session already started" | |
end | |
self.ca_file = '/opt/local/share/curl/ca-bundle.crt' if File.exists?('/opt/local/share/curl/ca-bundle.crt') && flag | |
@use_ssl = flag | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OSX Lion is strangely setup when it comes to OpenSSL CRT files. In Linux these are usually found in /etc/ssl/certs but this isn't the case with Mac. Whenever I tried to place the CRT file in what appeared to be default folders, it wouldn't work.
But this does.
Just add this one line (self.ca_file = ...) and point it to your ca_file.
This is a really ugly hack but was necessary to fix a bunch of scripts I couldn't modify.
A far better solution is to override (monkey match) use_ssl in your app.