Trying to download a file via HTTPS

Here is what I have in my recipes/default.rb.

if node[:platform] == 'ubuntu'
remote_file '/tmp/test.txt' do
source 'https://server1.example.com/pub/test.txt'
owner 'root'
group 'root'
mode '0755'
action :create
end
end

I am getting this error.
" [2020-02-27T18:27:10+00:00] FATAL: OpenSSL::SSL::SSLError: remote_file[/tmp/test.txt] (installInfraServer::default line 108) had an error: OpenSSL::SSL::SSLError: SSL Error connecting to https://server1.example.com/pub/test.txt - SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate)"

A newbee,
j

You are receiving this error because you are connecting to your remote source using https (secure http) with a self-signed cert. You either need to get a CA signed cert or add your certificate to the cacert usually found at /opt/chef/embedded/ssl/certs/cacert.pem

Thank you.

I have added the serf-signed cert into the /opt/chef/embedded/ssl/certs/cacert.pem of the vagrant box.

I ran kitchen converge and got the error below.

[2020-02-27T23:38:31+00:00] FATAL: OpenSSL::SSL::SSLError: remote_file[/tmp/test.txt] (installInfraServer::default line 108) had an error: OpenSSL::SSL::SSLError: SSL Error connecting to https://server1.example.com/pub/test.txt - SSL_connect returned=1 errno=0 state=error: certificate verify failed (error number 1)

It started working when I used the CNAME in the cert rather than the hostname in my recipe.

Thank you for the help. :slight_smile: