From 576047d919bd23d2eb358abbd4841e6ea9a8abfb Mon Sep 17 00:00:00 2001 From: orenbm Date: Thu, 29 Oct 2020 12:55:59 +0200 Subject: [PATCH] Add ability to provide cert store We would like to let users be able to provide their own cert store without the client initializing it. --- lib/websocket-client-simple/client.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/websocket-client-simple/client.rb b/lib/websocket-client-simple/client.rb index 128f523..cd2811a 100644 --- a/lib/websocket-client-simple/client.rb +++ b/lib/websocket-client-simple/client.rb @@ -23,8 +23,11 @@ def connect(url, options={}) ctx = OpenSSL::SSL::SSLContext.new ctx.ssl_version = options[:ssl_version] || 'SSLv23' ctx.verify_mode = options[:verify_mode] || OpenSSL::SSL::VERIFY_NONE #use VERIFY_PEER for verification - cert_store = OpenSSL::X509::Store.new - cert_store.set_default_paths + cert_store = options[:cert_store] + unless cert_store + cert_store = OpenSSL::X509::Store.new + cert_store.set_default_paths + end ctx.cert_store = cert_store @socket = ::OpenSSL::SSL::SSLSocket.new(@socket, ctx) @socket.connect