Skip to content

Commit

Permalink
support new version of ruby-tls
Browse files Browse the repository at this point in the history
remove ruby 19 from the test matrix
  • Loading branch information
Stephen von Takach committed Mar 6, 2015
1 parent 925125c commit 6ca3398
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: ruby
rvm:
- "1.9.3"
- "2.0.0"
- "2.1"
- "2.2"
- ruby-head
- rbx-2
- jruby-19mode
- jruby-20mode
branches:
only:
- master
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ Windows users will additionally require:

- A copy of Visual Studio 2010 or later. [Visual Studio Express](http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products) works fine.
- A copy of [OpenSSL](http://slproweb.com/products/Win32OpenSSL.html) matching the installed ruby (x86 / x64)
- with the environmental variable `OPENSSL_CONF` Set `OPENSSL_CONF=X:\path_to\OpenSSL\bin\openssl.cfg`
- If using jRuby then [GCC](http://win-builds.org/stable/) is also required
- Setup the paths as described on the gcc page
- Add required environmental variable `set LIBRARY_PATH=X:\win-builds-64\lib;X:\win-builds-64\x86_64-w64-mingw32\lib`
Expand Down
3 changes: 2 additions & 1 deletion lib/libuv/ext/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class UvAddrinfo < FFI::Struct
:udp_send,
:fs,
:work,
:getaddrinfo, # end UV_REQ_TYPE_MAP
:getaddrinfo,
:getnameinfo, # end UV_REQ_TYPE_MAP
:req_type_private,
:req_type_max
]
Expand Down
29 changes: 22 additions & 7 deletions lib/libuv/tcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ def initialize(loop, acceptor = nil)
def start_tls(args = {})
return unless @connected && @tls.nil?

args[:verify_peer] = true if @on_verify

@handshake = false
@pending_writes = []
@tls = ::RubyTls::Connection.new(self)
@tls.start(args)
@tls = ::RubyTls::SSL::Box.new(args[:server], self, args)
@tls.start
end

# Push through any pending writes when handshake has completed
Expand All @@ -69,7 +71,7 @@ def dispatch_cb(data)
# We resolve the existing tls write promise with a the
# real writes promise (a close may have occurred)
def transmit_cb(data)
if not @pending_write.nil?
if @pending_write
@pending_write.resolve(direct_write(data))
@pending_write = nil
else
Expand All @@ -79,7 +81,7 @@ def transmit_cb(data)

# Close can be called multiple times
def close_cb
if not @pending_write.nil?
if @pending_write
@pending_write.reject(TLS_ERROR)
@pending_write = nil
end
Expand All @@ -88,6 +90,19 @@ def close_cb
close
end

def verify_cb(cert)
if @on_verify
begin
return @on_verify.call cert
rescue => e
@loop.log :warn, :tls_verify_callback_failed, e
return false
end
end

true
end

# overwrite the default close to ensure
# pending writes are rejected
def close
Expand All @@ -102,7 +117,7 @@ def close
end
@connected = false

if not @pending_writes.nil?
if @pending_writes
@pending_writes.each do |deferred, data|
deferred.reject(TLS_ERROR)
end
Expand All @@ -113,8 +128,8 @@ def close
end

# Verify peers will be called for each cert in the chain
def verify_peer(&block)
@tls.verify_cb &block
def verify_peer(callback = nil, &blk)
@on_verify = callback || blk
end

alias_method :direct_write, :write
Expand Down
2 changes: 1 addition & 1 deletion lib/libuv/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Libuv
VERSION = '1.1.3'
VERSION = '1.2.0'
end
2 changes: 1 addition & 1 deletion libuv.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |gem|

gem.add_runtime_dependency 'ffi', '>= 1.9'
gem.add_runtime_dependency 'thread_safe'
gem.add_runtime_dependency 'ruby-tls', '>= 1.0.3'
gem.add_runtime_dependency 'ruby-tls', '>= 2.0.0'

gem.add_development_dependency 'rspec', '>= 2.14'
gem.add_development_dependency 'rake', '>= 10.1'
Expand Down

0 comments on commit 6ca3398

Please sign in to comment.