Skip to content

Instantly share code, notes, and snippets.

@claudijd
Created June 28, 2013 14:35
Show Gist options
  • Save claudijd/5885143 to your computer and use it in GitHub Desktop.
Save claudijd/5885143 to your computer and use it in GitHub Desktop.
Ruby OpenSSL verify peer enabled, empty cert store IRB example
>> require 'socket'
=> true
>> require 'openssl'
=> true
>>
?> ssl_context = OpenSSL::SSL::SSLContext.new
=> #<OpenSSL::SSL::SSLContext:0x007fc4a09e3740>
>> ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
=> 1
>> tcp_client = TCPSocket.new 'server.trustwave.com', 443
=> #<TCPSocket:fd 5>
>> ssl_client = OpenSSL::SSL::SSLSocket.new tcp_client, ssl_context
=> #<OpenSSL::SSL::SSLSocket:0x007fc4a09fb688>
>> ssl_client.connect
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
from (irb):8:in `connect'
from (irb):8
from /Users/jclaudius/.rvm/rubies/ruby-1.9.3-p392/bin/irb:16:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment