From c495fb7c5c72f8f3d77280dd085bf62d32553cc5 Mon Sep 17 00:00:00 2001 From: Simon Thulbourn Date: Tue, 21 May 2013 11:39:43 +0100 Subject: [PATCH 1/6] adds options for client certs to downloader class Adds :client_cert to the env array and then passes it into the curl options array --- lib/vagrant/util/downloader.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/vagrant/util/downloader.rb b/lib/vagrant/util/downloader.rb index ccf483b94..38453c404 100644 --- a/lib/vagrant/util/downloader.rb +++ b/lib/vagrant/util/downloader.rb @@ -18,6 +18,7 @@ module Vagrant options ||= {} @insecure = options[:insecure] @ui = options[:ui] + @client_cert = options[:client_cert] end # This executes the actual download, downloading the source file @@ -36,6 +37,7 @@ module Vagrant ] options << "--insecure" if @insecure + options << "--cert" << @client_cert if @client_cert options << @source # Specify some options for the subprocess From e216b9a1d25d64ad166fec41c28b511467039194 Mon Sep 17 00:00:00 2001 From: Simon Thulbourn Date: Tue, 21 May 2013 11:41:15 +0100 Subject: [PATCH 2/6] adds param for client certs adds an option to the command parser for client certicates --- plugins/commands/box/command/add.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/commands/box/command/add.rb b/plugins/commands/box/command/add.rb index 7f6829c7d..ebed09143 100644 --- a/plugins/commands/box/command/add.rb +++ b/plugins/commands/box/command/add.rb @@ -19,6 +19,11 @@ module VagrantPlugins options[:insecure] = i end + o.on("--cert certfile", String, + "The client SSL cert") do |c| + options[:client_cert] = c + end + o.on("--provider provider", String, "The provider that backs the box.") do |p| options[:provider] = p @@ -40,6 +45,7 @@ module VagrantPlugins :box_url => argv[1], :box_force => options[:force], :box_download_insecure => options[:insecure], + :box_client_cert => options[:client_cert] }) # Success, exit status 0 From 7dd7957a97a5da5636dc52e2eb0fede58a923434 Mon Sep 17 00:00:00 2001 From: Simon Thulbourn Date: Tue, 21 May 2013 11:42:19 +0100 Subject: [PATCH 3/6] adds client cert --- lib/vagrant/action/builtin/box_add.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/vagrant/action/builtin/box_add.rb b/lib/vagrant/action/builtin/box_add.rb index f0813092f..e24004cb2 100644 --- a/lib/vagrant/action/builtin/box_add.rb +++ b/lib/vagrant/action/builtin/box_add.rb @@ -29,6 +29,7 @@ module Vagrant downloader_options = {} downloader_options[:insecure] = env[:box_download_insecure] downloader_options[:ui] = env[:ui] + downloader_options[:client_cert] = env[:box_client_cert] # Download the box to a temporary path. We store the temporary # path as an instance variable so that the `#recover` method can From ad96a84afe411cfb4974cf90d2072f00434a40f0 Mon Sep 17 00:00:00 2001 From: Simon Thulbourn Date: Thu, 23 May 2013 14:11:56 +0100 Subject: [PATCH 4/6] adds client cert to default config --- config/default.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/default.rb b/config/default.rb index 97f92fc53..099ff55ab 100644 --- a/config/default.rb +++ b/config/default.rb @@ -14,6 +14,7 @@ Vagrant.configure("2") do |config| config.vm.usable_port_range = (2200..2250) config.vm.box_url = nil config.vm.base_mac = nil + config.vm.client_cert = nil config.vm.graceful_halt_retry_count = 60 config.vm.graceful_halt_retry_interval = 1 config.vm.guest = :linux From 97f9206787dae4b30aeb3a3775f58e37c93dddcf Mon Sep 17 00:00:00 2001 From: Simon Thulbourn Date: Thu, 23 May 2013 14:44:52 +0100 Subject: [PATCH 5/6] adds accessor for client_cert --- plugins/kernel_v2/config/vm.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 89f70b5c5..474f1005e 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -15,6 +15,7 @@ module VagrantPlugins attr_accessor :base_mac attr_accessor :box + attr_accessor :client_cert attr_accessor :box_url attr_accessor :graceful_halt_retry_count attr_accessor :graceful_halt_retry_interval From ef98c7b8b1d5225b5a0b9d84145d248e2cd65992 Mon Sep 17 00:00:00 2001 From: Simon Thulbourn Date: Thu, 23 May 2013 15:13:04 +0100 Subject: [PATCH 6/6] passes client cert option from Vagrant file to box_add --- lib/vagrant/action/builtin/handle_box_url.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/action/builtin/handle_box_url.rb b/lib/vagrant/action/builtin/handle_box_url.rb index 7cbac6570..5116c05a3 100644 --- a/lib/vagrant/action/builtin/handle_box_url.rb +++ b/lib/vagrant/action/builtin/handle_box_url.rb @@ -27,8 +27,9 @@ module Vagrant # We can assume a box URL is set because the Vagrantfile # validation should do this for us. If not, though, we do # raise a terrible runtime error. - box_name = env[:machine].config.vm.box - box_url = env[:machine].config.vm.box_url + box_name = env[:machine].config.vm.box + box_url = env[:machine].config.vm.box_url + box_client_cert = env[:machine].config.vm.client_cert lock.synchronize do # First see if we actually have the box now. @@ -53,9 +54,10 @@ module Vagrant begin env[:action_runner].run(Vagrant::Action.action_box_add, { - :box_name => box_name, - :box_provider => env[:machine].provider_name, - :box_url => box_url + :box_name => box_name, + :box_provider => env[:machine].provider_name, + :box_url => box_url, + :box_client_cert => box_client_cert }) rescue Errors::BoxAlreadyExists # Just ignore this, since it means the next part will succeed!