Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trust self-signed certificate CentOS 7

I am generating a self-signed certificate for a development server but I need it to be trusted in order to use some of the tools that will be using the certificate.

This is what I have tried:

openssl req -newkey rsa:2048 -x509 -nodes -keyout /etc/ssl/private/server.key -new -out /etc/ssl/certs/server.crt -reqexts v3_req -extensions v3_req -config /vagrant/openssl.san.conf -sha256 -days 1825

ln --symbolic /etc/ssl/certs/server.crt /etc/pki/ca-trust/source/anchors/server.crt

update-ca-trust extract

I tried grepping the ca-bundle.crt file for the contents of server.crt after running the update-ca-trust command but it wasn't there.

I have also tried copying the file instead of making a symlink but that did not work either.

The certificate is created correctly and works for Apache but it produces the self-signed error:

[vagrant@localhost certs]$ curl --head https://localhost/
curl: (60) Issuer certificate is invalid.
More details here: http://curl.haxx.se/docs/sslcerts.html

How can I trust my self-signed certificate on the command line on the server?

like image 820
rink.attendant.6 Avatar asked Sep 28 '17 18:09

rink.attendant.6


1 Answers

Your problem is that update-ca-trust accepts only certificates marked as CA. There is a X.509 extension called Basic Constraints which is used to mark whether a certificate belongs to a CA or not. update-ca-trust silently skips those not marked as CA.

Check your certificate for the CA constraint:

openssl x509 -noout -text -in <cert_file> | grep "CA:TRUE"

The CA:TRUE can be set using the OpenSSL config.

like image 185
Yuri Avatar answered Sep 23 '22 10:09

Yuri