Ruby SSL with Twitter failed on cert OpenSSL issue on Windows 7
So I dug around and basically stared at the hard coded path of the certs. By typing this at the command line
ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE'
I got the following...
c:/Users/Luis/Code/openknapsack/knap-build/var/knapsack/software/x86-windows/openssl/1.0.0k/ssl/cert.pem
So my solution was to first download cacert.pem from http://curl.haxx.se/ca/cacert.pem to c:\ . Then open up Windows Control Panel -> Administrative Tools -> Windows PowerShell Modules. Then I proceeded to type out:
cd \
cd users
mkdir Luis
cd Luis
mkdir Code
cd Code
mkdir openknapsack
cd openknapsack
mkdir knap-build
cd knap-build
mkdir var
cd var
mkdir knapsack
cd knapsack
mkdir software
cd software
mkdir x86-windows
cd x86-windows
mkir openssl
cd openssl
mkdir 1.0.0k
cd 1.0.0k
mkdir ssl
cd ssl
cp c:\cacert.pem .\cert.pem
And now everything works! Yes it's a cheap hack and it's ugly. But now both you and I can get back to doing serious coding and not worry about pesky problems.
I know it's not a great fix, but it's the only thing that worked for me, and it should for you too.
If some one would like to write a PowerShell script to auto install the cert file into this directory then you could more easily deploy your Ruby project to Windows 7. Just a thought.
By the way, you can duplicate this process for any operating system should the need arise. Just find the path the cert file belongs in with:
ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE'
And be sure to rename the file as it appears in the ouput!
How to solve certificate verify failed on Windows?
Actually the best way I found to solve this in windows for Ruby itself, not just one gem, is to do the following:
- Download https://curl.haxx.se/ca/cacert.pem into c:\railsinstaller\cacert.pem. Make sure you save it as a .pem file, rather than a text file.
- Go to your Computer -> Advanced Settings -> Environment Variables
Create a new System Variable:
Variable: SSL_CERT_FILE
Value: C:\RailsInstaller\cacert.pemClose all your command prompts, including your Rails server command prompt, etc.
Start a new ruby irb prompt, and try the following:
$irb>require 'open-uri'
$irb>open('https://www.gmail.com')
It should all work now just fine.
ERROR: While executing gem ... (OpenSSL::X509::StoreError)
TRy this in your command line
ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE'
Also see OpenSSL::X509::StoreError: cert already in hash table? and SSL Error When installing rubygems, Unable to pull data from 'https://rubygems.org/.
Ruby Gem Twitter - certificate verify failed (Twitter::Error::ClientError)
I was able to solve my own question. For those having the same issue try using the following:
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
It disables the SSL security but it allows you to process with troubleshooting. The underlying issue is an outdated SSL.
Related Topics
Exception_Notification for Delayed_Job
Using Activemodel::Serializer in Rails - JSON Data Differs Between JSON and Index Response
Log Doesn't Work in Production with Delayed Job
Rails Routes: Get Without Param :Id
In Ruby, How to Find Out If a String Is Not in an Array
Ruby -V Dyld: Library Not Loaded: /Usr/Local/Lib/Libgmp.10.Dylib
Is It a Good Idea to Purge Old Rails Migration Files
Rails 3.2.8 - How to Get the Week Number from Rails
How to Reference a Method in Another Ruby Code File
Specifying Content Type in Rspec
Case Expression Different in Ruby 1.9
Ruby 1.9.2 - Read and Parse a Remote CSV
Sidekiq Worker Not Getting Triggered
How Can One Set Property Values When Initializing an Object in Ruby