信任自签名证书CentOS 7

rin*_*t.6 6 certificate ca self-signed ssl-certificate centos7

我正在为开发服务器生成一个自签名证书,但我需要它才能被信任才能使用一些将使用该证书的工具.

这是我尝试过的:

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
Run Code Online (Sandbox Code Playgroud)

在尝试运行update-ca-trust命令之后,我尝试使用grepping ca-bundle.crt文件获取内容,server.crt但它不在那里.

我也尝试过复制文件而不是制作符号链接,但这也不起作用.

证书是正确创建的,适用于Apache,但它会产生自签名错误:

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

如何在服务器的命令行上信任我的自签名证书?

小智 1

我只需发出以下命令并在“通用名称”部分中填写我的私有 DNS 名称。

openssl req  -new -x509 -newkey rsa:2048 -nodes  -keyout ca.key -days 365 -out ca.crt
Run Code Online (Sandbox Code Playgroud)

执行以下命令后,自签名证书将被信任。

cp ca.crt /etc/pki/ca-trust/source/anchors/
update-ca-trust extract
Run Code Online (Sandbox Code Playgroud)