class T2Server::HttpsConnection

A class representing a https connection to a Taverna Server. This class should only ever be created via the T2Server::Connection factory class.

Public Class Methods

new(uri, params = nil) click to toggle source

Open a https connection to the Taverna Server at the uri supplied.

Calls superclass method T2Server::HttpConnection::new
    # File lib/t2-server/net/connection.rb
302 def initialize(uri, params = nil)
303   super(uri, params)
304 
305   if OpenSSL::SSL::SSLContext::METHODS.include? @params[:ssl_version]
306     @http.ssl_version = @params[:ssl_version]
307   end
308 
309   set_peer_verification
310   set_client_authentication
311 end

Private Instance Methods

set_client_authentication() click to toggle source
    # File lib/t2-server/net/connection.rb
339 def set_client_authentication
340   if @params[:client_certificate]
341     cert = File.read(@params[:client_certificate])
342     pkcs12 = OpenSSL::PKCS12.new(cert, @params[:client_password])
343     @http.certificate = pkcs12.certificate
344     @http.private_key = pkcs12.key
345   end
346 end
set_peer_verification() click to toggle source
    # File lib/t2-server/net/connection.rb
315 def set_peer_verification
316   if @params[:verify_peer]
317     if @params[:ca_file]
318       @http.ca_file = @params[:ca_file]
319     end
320 
321     if @params[:ca_path]
322       store = OpenSSL::X509::Store.new
323       store.set_default_paths
324       if @params[:ca_path].is_a? Array
325         @params[:ca_path].each { |path| store.add_path(path) }
326       else
327         store.add_path(@params[:ca_path])
328       end
329 
330       @http.cert_store = store
331     end
332 
333     @http.verify_mode = OpenSSL::SSL::VERIFY_PEER
334   else
335     @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
336   end
337 end