Last active
August 29, 2015 14:15
-
-
Save johngtimms/0c42c687b1c0e9022cbf to your computer and use it in GitHub Desktop.
Ruby script for exposing SSL_CERT_PATH error in Excon on Windows
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
C:\Users\John\CW-Excon-Test>ruby excon_test.rb | |
DL is deprecated, please use Fiddle | |
Starting test... | |
Uploading pic.jpg... | |
C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/ssl_socket.rb:121:in `connect_nonblock': Unable to verify certificate, please set `E | |
xcon.defaults[:ssl_ca_path] = path_to_certs`, `ENV['SSL_CERT_DIR'] = path_to_certs`, `Excon.defaults[:ssl_ca_file] = path_to_file`, `ENV['SS | |
L_CERT_FILE'] = path_to_file`, `Excon.defaults[:ssl_verify_callback] = callback` (see OpenSSL::SSL::SSLContext#verify_callback), or `Excon.d | |
efaults[:ssl_verify_peer] = false` (less secure). (Excon::Errors::SocketError) | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/ssl_socket.rb:121:in `block in initialize' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/ssl_socket.rb:119:in `loop' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/ssl_socket.rb:119:in `initialize' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/connection.rb:387:in `new' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/connection.rb:387:in `socket' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/connection.rb:106:in `request_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/mock.rb:47:in `request_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/instrumentor.rb:22:in `request_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/base.rb:15:in `request_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/base.rb:15:in `request_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/base.rb:15:in `request_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/connection.rb:233:in `request' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/idempotent.rb:26:in `error_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/base.rb:10:in `error_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/base.rb:10:in `error_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/connection.rb:256:in `rescue in request' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/connection.rb:204:in `request' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/idempotent.rb:26:in `error_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/base.rb:10:in `error_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/base.rb:10:in `error_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/connection.rb:256:in `rescue in request' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/connection.rb:204:in `request' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/idempotent.rb:26:in `error_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/base.rb:10:in `error_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/middlewares/base.rb:10:in `error_call' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/connection.rb:256:in `rescue in request' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/excon-0.44.1/lib/excon/connection.rb:204:in `request' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/fog-core-1.28.0/lib/fog/core/connection.rb:63:in `request' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/fog-xml-0.1.1/lib/fog/xml/connection.rb:9:in `request' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/fog-aws-0.1.0/lib/fog/aws/storage.rb:586:in `_request' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/fog-aws-0.1.0/lib/fog/aws/storage.rb:581:in `request' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/fog-aws-0.1.0/lib/fog/aws/requests/storage/put_object.rb:43:in `put_object' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/fog-aws-0.1.0/lib/fog/aws/models/storage/file.rb:208:in `save' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/fog-core-1.28.0/lib/fog/core/collection.rb:51:in `create' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/storage/fog.rb:261:in `store' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/storage/fog.rb:80:in `store!' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/store.rb:59:in `block in store!' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/callbacks.rb:17:in `with_callbacks' | |
from C:/Ruby/lib/ruby/gems/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/store.rb:58:in `store!' | |
from excontest.rb:60:in `block in <main>' | |
from excontest.rb:59:in `open' | |
from excontest.rb:59:in `<main>' | |
C:\Users\John\CW-Excon-Test> |
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
require 'carrierwave' | |
require 'fog' | |
# My installed versions: | |
# | |
# Windows 7 x64 | |
# ruby 2.1.5p273 (2014-11-13 revision 48405) [x64-mingw32] | |
# gem 2.4.5 | |
# excon (0.44.1) | |
# carrierwave (0.10.0) | |
# fog (1.27.0) | |
# Output of the following tests: | |
# | |
# puts Excon.defaults[:ssl_ca_path] => | |
# puts ENV['SSL_CERT_DIR'] => | |
# puts Excon.defaults[:ssl_ca_file] => | |
# puts ENV['SSL_CERT_FILE'] => C:\Ruby\ca-bundle.crt | |
# puts Excon.defaults[:ssl_verify_callback] => | |
# puts Excon.defaults[:ssl_verify_peer] => true | |
# Set variables here | |
CACHE_DIRECTORY = "uploads" # Any directory you want. Will be created in the directory where this script runs. | |
FOG_DIR = "excon-test" # The S3 bucket where you want to upload. | |
STORE_DIRECTORY = "test" # The folder inside the S3 bucket you want to use. | |
AWS_ID = "" | |
AWS_SECRET = "" | |
FILE_PATH = "pic.jpg" # The path + file you want to test with | |
CarrierWave.configure do |config| | |
config.cache_dir = CACHE_DIRECTORY | |
config.fog_directory = FOG_DIR | |
config.fog_credentials = { | |
:provider => 'AWS', | |
:aws_access_key_id => AWS_ID, | |
:aws_secret_access_key => AWS_SECRET | |
} | |
end | |
class TestUploader < CarrierWave::Uploader::Base | |
storage :fog | |
def store_dir | |
STORE_DIRECTORY | |
end | |
end | |
puts "Starting test..." | |
puts "Uploading #{FILE_PATH}..." | |
puts "" | |
uploader = TestUploader.new | |
File.open(FILE_PATH) do |f| | |
upload = uploader.store!(f) ## The error will happen here | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment