1

I used this tool in this link to generate a self-signed certificate for a Windows webserver.

The command to generate the cert is like following

New-SelfSignedCertificateEx -Subject "CN=192.168.56.111" -SAN "192.168.56.111" -IsCA $true -EKU "Server Authentication", "Client Authentication" -KeyLength 2048  -KeySpec "Signature" -KeyUsage "DigitalSignature" -FriendlyName "192.168.56.111" -NotAfter $([datetime]::now.AddYears(5)) -StoreLocation "LocalMachine" -Exportable

After installing the certificate with IIS, and add the certificate to the trusted root CA store in a Windows 10 client, I was able to browse the website with no certificate errors.

However when I try to do the same in a ubuntu 18.04 client by installing the cert to the CA certs store and test using cURL, it doesn't work

Install cert to Ubuntu ca-certificates

openssl s_client -connect 192.168.56.111:443 -showcerts > out.txt
#then use vim to edit out.txt and save the cert to 192.168.56.111.crt

sudo cp 192.168.56.111.crt /usr/local/share/ca-certificates
sudo update-ca-certificates

Test the connection using cURL

curl https://192.168.56.111

And got the error message

curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

When adding the cert to the Chrome Certifiates store, Chrome shows NET::ERR_CERT_INVALID

So my question is, why does it work in Windows client but not in Ubuntu 18.04? I can't see any error indicating what's wrong with the certificate in Ubuntu so I'm stuck at the moment.

stormtrooper
  • 340
  • 2
  • 18

1 Answers1

0

Your openssl command is not correct:

jonathan.muller@jonathan-muller-C02ZC4EPLVDQ$ openssl s_client -connect drylm.org:443 -showcerts
CONNECTED(00000005)
depth=2 O = Digital Signature Trust Co., CN = DST Root CA X3
verify return:1
depth=1 C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
verify return:1
depth=0 CN = blog.drylm.org
verify return:1
---
Certificate chain
 0 s:/CN=blog.drylm.org
   i:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
-----BEGIN CERTIFICATE-----
MIIFUzCCBDugAwIBAgISA0xYp5ZHU+NGF1EW/RcUuV0fMA0GCSqGSIb3DQEBCwUA
...

you have a lot of noise in the output. Here is how to extract the certificate:

echo | openssl s_client -connect 192.168.56.111:443 2>/dev/null | openssl x509 > 192.168.56.111.pem

and you can copy this pem file to the truststore.

Edit:

I just made the exercise by creating a self sign certificate on this website

in my shell:

john@kona$ curl https://test.drylm.org
curl: (60) SSL certificate problem: self signed certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

then

john@kona$ echo | openssl s_client -connect test.drylm.org:443 2>/dev/null | openssl x509 > test.drylm.org.crt
sudo cp test.drylm.org.crt /usr/local/share/ca-certificates/
john@kona$ sudo update-ca-certificates 
Updating certificates in /etc/ssl/certs...
1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

Adding debian:test.drylm.org.pem
done.
done.

and finally:

john@kona$ curl https://test.drylm.org
      Path : ~  

No more error message with curl.

Bhaal22
  • 715
  • 4
  • 10
  • Please read the question, the cert is extracted correctly manually using Vim. Also, the openssl command to extract is the same as what you wrote. You didn't answer the question. – stormtrooper Jun 03 '20 at 14:22
  • it's fine. "edit the file with vim" indeed can mean a lot of things. the command I share with you avoid you to make any manual potential mistakes. maybe give a try. – Bhaal22 Jun 03 '20 at 14:23
  • After running the command and reinstall the cert, it still shows the same error when testing with cURL. – stormtrooper Jun 03 '20 at 14:34
  • even if you copy the file as a .crt file? just read update-ca-certificates process only .crt files. – Bhaal22 Jun 03 '20 at 14:45
  • The certificate installation is not the issue, I can see it in /etc/ssl/certs. The issue is cURL shows ssl error despite the cert being installed correctly. – stormtrooper Jun 04 '20 at 00:44
  • and what shows curl -v ? I will retry to process using a ubuntu 18.04 container. – Bhaal22 Jun 04 '20 at 07:42