Created
June 26, 2012 21:17
-
-
Save jordansissel/2999123 to your computer and use it in GitHub Desktop.
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
% rvm 1.6.7 do ruby --1.9 nonblock.rb | |
SSLSocket.java:196:in `connect_nonblock': java.lang.UnsupportedOperationException | |
from SSLSocket$i$0$0$connect_nonblock.gen:65535:in `call' | |
from CachingCallSite.java:292:in `cacheAndCall' |
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
% rvm jruby-1.7.0.preview1 do ruby --1.9 nonblock.rb | |
NoMethodError: undefined method `connect_nonblock' for #<OpenSSL::SSL::SSLSocket:0x516f5228> | |
(root) at nonblock.rb:13 |
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
% rvm 1.9.3 do ruby nonblock.rb | |
connect_nonblock done |
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 "openssl" | |
require "socket" | |
sslcontext = OpenSSL::SSL::SSLContext.new | |
sslcontext.ssl_version = "TLSv1" | |
# The OpenSSL docs seem to indicate that 'verify_callback' | |
sslcontext.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
tcp = TCPSocket.new("twitter.com", 443) | |
tls = OpenSSL::SSL::SSLSocket.new(tcp, sslcontext) | |
begin | |
tls.connect_nonblock | |
rescue OpenSSL::SSL::SSLError => e | |
raise e if e.to_s !~ /read would block/ | |
retry | |
end | |
puts "connect_nonblock done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment