curl self-signed certificate web service over SSL

戏子无情 提交于 2019-12-04 16:46:09

In case anyone runs into this in the future, I had to create the cert for localhost.com and add it to the end of my /etc/hosts file like this and then curl --cacert cert.crt https://localhost.com.

127.0.0.1   localhost
127.0.0.1   localhost.com

If you are not on linux or mac, you can try this in a docker container which will have /etc/hosts.

I don't know why it wouldn't work with localhost as domain name, but curl would keep complaining about self-signed certs. Might have something to do with either docker networking or something special about the localhost keyword.

zmo

please refer to that following answer:

to sum up:

% openssl s_client -showcerts -connect example.com:443 </dev/null 2>/dev/null | sed -n '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p' | grep -m1 -B-1 -- '-----END CERTIFICATE-----'  > cert.pem
% curl --cacert cert.pem https://example.com

and tada, you connect securely to a self-signed website.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!