Skip to content

Commit

Permalink
Add "ssl_ca_file" in config for self-signed certs
Browse files Browse the repository at this point in the history
  • Loading branch information
akitada committed May 17, 2017
1 parent 2978da1 commit 1f68d60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions source/lib/vagrant-openstack-provider/client/rest_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ def self.get(env, url, headers = {}, &block)
config = env[:machine].provider_config
RestClient::Request.execute(method: :get, url: url, headers: headers,
timeout: config.http.read_timeout, open_timeout: config.http.open_timeout,
verify_ssl: config.ssl_verify_peer, &block)
ssl_ca_file: config.ssl_ca_file, verify_ssl: config.ssl_verify_peer, &block)
end

def self.post(env, url, payload, headers = {}, &block)
config = env[:machine].provider_config
RestClient::Request.execute(method: :post, url: url, payload: payload, headers: headers,
timeout: config.http.read_timeout, open_timeout: config.http.open_timeout,
verify_ssl: config.ssl_verify_peer, &block)
ssl_ca_file: config.ssl_ca_file, verify_ssl: config.ssl_verify_peer, &block)
end

def self.delete(env, url, headers = {}, &block)
config = env[:machine].provider_config
RestClient::Request.execute(method: :delete, url: url, headers: headers,
timeout: config.http.read_timeout, open_timeout: config.http.open_timeout,
verify_ssl: config.ssl_verify_peer, &block)
ssl_ca_file: config.ssl_ca_file, verify_ssl: config.ssl_verify_peer, &block)
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions source/lib/vagrant-openstack-provider/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ class Config < Vagrant.plugin('2', :config)
# @return [Boolean]
attr_accessor :use_legacy_synced_folders

# Specify the certificate to use.
#
# @return [String]
attr_accessor :ssl_ca_file

# Verify ssl peer certificate when connecting. Set to false (! unsecure) to disable
#
# @return [Boolean]
Expand Down Expand Up @@ -295,6 +300,7 @@ def initialize
@meta_args_support = UNSET_VALUE
@http = HttpConfig.new
@use_legacy_synced_folders = UNSET_VALUE
@ssl_ca_file = UNSET_VALUE
@ssl_verify_peer = UNSET_VALUE
end

Expand Down Expand Up @@ -407,6 +413,7 @@ def finalize!
@volumes = nil if @volumes.empty?
@stacks = nil if @stacks.empty?
@http.finalize!
@ssl_ca_file = nil if @ssl_ca_file == UNSET_VALUE
@ssl_verify_peer = true if @ssl_verify_peer == UNSET_VALUE
end
# rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
Expand Down

0 comments on commit 1f68d60

Please sign in to comment.