将自签名证书添加到 ubuntu 以与curl 一起使用
我正在开发一个程序,其中有一个使用自签名证书运行的虚拟开发服务器。我的程序使用curl 连接到服务器并提取信息,但需要使用SSL 来完成此操作。当我尝试连接时,收到错误“SSL 证书问题,请验证 CA 证书是否正常。”运行 Firefox 时,我可以将证书添加到 Firefox,但这对我的curl 没有帮助。如何添加curl识别的证书?
卷曲 7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15 协议: tftp ftp telnet dict ldap ldaps http 文件 https ftps 功能: GSS-协商 IDN IPv6 大文件 NTLM SSL libz
Ubuntu 10.04 Lucid Lynx 64 位
I'm developing a program where I have a virtual development server that runs with a self signed certificate. My program uses curl to connect to the server and pull information, but needs to do so with SSL. When I try to connect I get the error "SSL certificate problem, verify that the CA cert is OK." When running firefox I can add the certificate to just firefox, but that doesn't help me with curl. How do I add the certificate for curl to recognize?
curl 7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz
Ubuntu 10.04 Lucid Lynx 64bit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是对我有用的一种方法:
首先,从开发域获取 CA 证书并将其保存到名为“logfile”的文件中。 (假设 SSL 端口为 443)
然后,使用 --cacert curl 选项来使用保存的证书文件。
来源:
http://curl.haxx.se/docs/sslcerts.html
This is one way that worked for me:
First, get the CA cert from the development domain and save it to a file called 'logfile'. (Assumes port 443 for SSL)
Then, use the --cacert curl option to use the saved certificate file.
Source:
http://curl.haxx.se/docs/sslcerts.html
我会将证书复制到
/usr/local/share/ca-certificates/
。让我引用 update-ca-certificates 的手册页:
I'd copy the certificate to
/usr/local/share/ca-certificates/
.Let me quote the man page for update-ca-certificates:
将 rootCA.pem 添加到
/usr/share/ca-certificates
目录中。之后使用以下命令更新您的证书:
update-ca-certificates --fresh
命令。我刚刚这样做了,效果很好。
Add your rootCA.pem in
/usr/share/ca-certificates
directory.After that update your certificates with:
update-ca-certificates --fresh
command.I just did that, and works fine.
首先,在 Linux 中,您应该将 CERTIFICATE.cert 添加到
/usr/local/share/ca-certificates/
。之后,通过将
--cacert CERTIFICATE.cert
添加到您的命令中,curl 将在该请求中自动使用此证书。经验:
curl --cacert CERTIFICATE.cert 获取“URL”。
显然,您可以编辑请求以获得所需的请求。
First, in your Linux, you should add your CERTIFICATE.cert to
/usr/local/share/ca-certificates/
.After that by adding
--cacert CERTIFICATE.cert
to your command, curl will automatically use this certificate in that request.Exp:
curl --cacert CERTIFICATE.cert GET "URL".
Obviously, you can edit the request to have your desired request.