Skip to content

Commit

Permalink
Merge pull request #18 from AlexisEvo/master
Browse files Browse the repository at this point in the history
Add support for custom TLS options, and enable SNI by default
  • Loading branch information
imanel committed Aug 21, 2018
2 parents 2893e4b + 8cc0f85 commit 1ab5dd6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/websocket/eventmachine/client.rb
Expand Up @@ -23,6 +23,7 @@ class Client < Base
# @option args [Integer] :version Version of protocol to use(default = 13)
# @option args [Hash] :headers HTTP headers to use in the handshake
# @option args [Boolean] :ssl Force SSL/TLS connection
# @option args [Hash] :tls TLS options hash to be passed to EM start_tls
def self.connect(args = {})
host = nil
port = nil
Expand All @@ -35,6 +36,8 @@ def self.connect(args = {})
host = args[:host] if args[:host]
port = args[:port] if args[:port]
if args[:ssl]
args[:tls] ||= {}
args[:tls][:sni_hostname] ||= host
port ||= 443
else
port ||= 80
Expand Down Expand Up @@ -83,7 +86,7 @@ def post_init
# @private
def connection_completed
if @args[:ssl]
start_tls
start_tls @args[:tls]
else
send(@handshake.to_s, :type => :plain)
end
Expand Down

0 comments on commit 1ab5dd6

Please sign in to comment.