mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Minor post-merge refactor, mainly moved duplicated method ca_bundle_path into common.rb
This commit is contained in:
10
lib/api.rb
10
lib/api.rb
@@ -1,16 +1,8 @@
|
|||||||
class W3DHub
|
class W3DHub
|
||||||
class Api
|
class Api
|
||||||
|
|
||||||
# Detect CA bundle path for Excon
|
|
||||||
def self.ca_bundle_path
|
|
||||||
redhat_path = '/etc/pki/tls/certs/ca-bundle.crt'
|
|
||||||
debian_path = '/etc/ssl/certs/ca-certificates.crt'
|
|
||||||
[redhat_path, debian_path].find { |path| File.exist?(path) }
|
|
||||||
end
|
|
||||||
|
|
||||||
# Set Excon default CA file if found
|
# Set Excon default CA file if found
|
||||||
ca_file = ca_bundle_path
|
if (ca_file = W3DHub.ca_bundle_path)
|
||||||
if ca_file
|
|
||||||
Excon.defaults[:ssl_ca_file] = ca_file
|
Excon.defaults[:ssl_ca_file] = ca_file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,6 @@ class W3DHub
|
|||||||
TAG = "IRCClient"
|
TAG = "IRCClient"
|
||||||
|
|
||||||
class SSL
|
class SSL
|
||||||
# Detect system CA bundle path for SSL verification
|
|
||||||
def self.ca_bundle_path
|
|
||||||
[
|
|
||||||
'/etc/ssl/certs/ca-certificates.crt', # Debian/Ubuntu
|
|
||||||
'/etc/pki/tls/certs/ca-bundle.crt', # RHEL/Fedora/CentOS
|
|
||||||
'/etc/ssl/ca-bundle.pem' # Some other distros
|
|
||||||
].find { |path| File.exist?(path) }
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.default_context
|
def self.default_context
|
||||||
verify_peer_and_hostname
|
verify_peer_and_hostname
|
||||||
end
|
end
|
||||||
@@ -33,8 +24,7 @@ class W3DHub
|
|||||||
no_verify.tap do |context|
|
no_verify.tap do |context|
|
||||||
context.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
context.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
||||||
context.cert_store = OpenSSL::X509::Store.new
|
context.cert_store = OpenSSL::X509::Store.new
|
||||||
ca_file = ca_bundle_path
|
if (ca_file = W3DHub.ca_bundle_path)
|
||||||
if ca_file
|
|
||||||
context.cert_store.add_file(ca_file)
|
context.cert_store.add_file(ca_file)
|
||||||
else
|
else
|
||||||
context.cert_store.set_default_paths
|
context.cert_store.set_default_paths
|
||||||
|
|||||||
@@ -32,6 +32,15 @@ class W3DHub
|
|||||||
linux? || mac?
|
linux? || mac?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Detect system CA bundle path for SSL verification
|
||||||
|
def self.ca_bundle_path
|
||||||
|
[
|
||||||
|
"/etc/ssl/certs/ca-certificates.crt", # Debian/Ubuntu
|
||||||
|
"/etc/pki/tls/certs/ca-bundle.crt", # RHEL/Fedora/CentOS
|
||||||
|
"/etc/ssl/ca-bundle.pem" # Some other distros
|
||||||
|
].find { |path| File.exist?(path) }
|
||||||
|
end
|
||||||
|
|
||||||
def self.url(path)
|
def self.url(path)
|
||||||
raise "Hazardous input: #{path}" if path.include?("&&") || path.include?(";")
|
raise "Hazardous input: #{path}" if path.include?("&&") || path.include?(";")
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ class W3DHub
|
|||||||
"Español"
|
"Español"
|
||||||
else
|
else
|
||||||
logger.warn("W3DHub::Settings") { "Unknown language code: #{string.inspect}" }
|
logger.warn("W3DHub::Settings") { "Unknown language code: #{string.inspect}" }
|
||||||
|
|
||||||
|
"UNKNOWN"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 528 KiB After Width: | Height: | Size: 795 KiB |
Reference in New Issue
Block a user