Skip to content

Instantly share code, notes, and snippets.

@bararchy
Created November 17, 2014 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bararchy/52385ca871d98a7c1909 to your computer and use it in GitHub Desktop.
Save bararchy/52385ca871d98a7c1909 to your computer and use it in GitHub Desktop.
So...
require 'ffi'
require 'socket'
module SSL_Client
extend FFI::Library
ffi_lib 'ssl'
attach_function :SSL_library_init, [], :int
attach_function :SSL_load_error_strings, [], :long
attach_function :SSLv3_client_method, [], :long
attach_function :SSL_CTX_new, [:long], :long
attach_function :SSL_new, [:long], :long
attach_function :SSL_set_fd, [:long, :long], :long
attach_function :SSL_connect, [:long], :int
end
SSL_Client.SSL_library_init
SSL_Client.SSL_load_error_strings
meth = SSL_Client.SSLv3_client_method
ctx = SSL_Client.SSL_CTX_new(meth)
ssl = SSL_Client.SSL_new(ctx)
sock = TCPSocket.new("192.168.0.4", 443)
SSL_Client.SSL_set_fd(ssl, sock.to_i)
err = SSL_Client.SSL_connect(ssl)
puts err
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment