Authenticate with certificate


#1

Hello guys,

I have an issue and I hope you can help me solve it.
I'm trying to download a zip file from a server using the remote_file resource. The problem is that on the remote server you need to authenticate with a trusted certificate. I already have the certificate installed on the system and if I use a browser I can download the file.

Thank you.


#2

I used an workaround because I couldn't made it with any chef built-in resources. I used chocolatey to install wget for windows.

include_recipe 'chocolatey::default'

tmp_path = Chef::Config[:file_cache_path]

%w(cert.pem key.pem).each do |file|
  cookbook_file "#{tmp_path}\\#{file}" do
    source file
    action :create
  end
end

batch 'install wget' do
  code <<-EOH
    choco install -y wget
  EOH
  action :run
end

batch 'download artifact' do
  cwd tmp_path
  code <<-EOH
    wget --certificate cert.pem --private-key=key.pem https://server.url:9443/nexus/repository/releases/artifact.zip
  EOH
  action :run
end