Skip to content

Instantly share code, notes, and snippets.

View claudijd's full-sized avatar
🦬

Jonathan Claudius claudijd

🦬
View GitHub Profile
@claudijd
claudijd / example.rb
Created June 28, 2013 14:21
OpenSSL Connection Source - no verify, no cert store
require 'socket'
require 'openssl'
ssl_context = OpenSSL::SSL::SSLContext.new
tcp_client = TCPSocket.new 'server.trustwave.com', 443
ssl_client = OpenSSL::SSL::SSLSocket.new tcp_client, ssl_context
ssl_client.connect
@claudijd
claudijd / example2.rb
Created June 28, 2013 14:28
OpenSSL no verify, no cert store IRB example
>> require 'socket'
=> true
>> require 'openssl'
=> true
>>
?> ssl_context = OpenSSL::SSL::SSLContext.new
=> #<OpenSSL::SSL::SSLContext:0x007f8b53049058>
>> tcp_client = TCPSocket.new 'server.trustwave.com', 443
=> #<TCPSocket:fd 5>
>> ssl_client = OpenSSL::SSL::SSLSocket.new tcp_client, ssl_context
@claudijd
claudijd / example3.rb
Created June 28, 2013 14:31
Default Ruby OpenSSL Verify Mode
>> ssl_context.verify_mode
=> nil
@claudijd
claudijd / example4.rb
Created June 28, 2013 14:35
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
@claudijd
claudijd / example5.rb
Created June 28, 2013 14:38
Default Ruby OpenSSL cert_store
>> ssl_context.cert_store
=> nil
@claudijd
claudijd / example5.rb
Created June 28, 2013 14:40
Ruby OpenSSL using verify peer and system cert store.
>> require 'socket'
=> true
>> require 'openssl'
=> true
>>
?> ssl_context = OpenSSL::SSL::SSLContext.new
=> #<OpenSSL::SSL::SSLContext:0x007ffc9a9deb00>
>> ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
=> 1
>> cert_store = OpenSSL::X509::Store.new
@claudijd
claudijd / example6.rb
Created June 28, 2013 14:45
httpclient SSLConfig initlialization
# Creates a SSLConfig.
def initialize(client)
return unless SSLEnabled
@client = client
@cert_store = X509::Store.new
@client_cert = @client_key = @client_ca = nil
@verify_mode = SSL::VERIFY_PEER | SSL::VERIFY_FAIL_IF_NO_PEER_CERT
@verify_depth = nil
@verify_callback = nil
@dest = nil
@claudijd
claudijd / example7.rb
Created June 28, 2013 14:47
httpclient #set_default_paths
def set_default_paths
@cacerts_loaded = true # avoid lazy override
@cert_store = X509::Store.new
@cert_store.set_default_paths
change_notify
end
@claudijd
claudijd / example8.rb
Created June 28, 2013 14:48
Handsoap http_client_driver implementation
# -*- coding: utf-8 -*-
require 'handsoap/http/drivers/abstract_driver'
module Handsoap
module Http
module Drivers
class HttpClientDriver < AbstractDriver
def self.load!
require 'httpclient'
end
@claudijd
claudijd / example9.rb
Created June 28, 2013 14:49
Monkey Patched handsoap http_client_driver implementation
require 'handsoap/http/drivers/abstract_driver'
module Handsoap
module Http
module Drivers
class HttpClientDriver < AbstractDriver
def self.load!
require 'httpclient'
end