我一直在玩弄 Curl,尝试将文件简单地 POST 到 Web 服务几天,但一无所获。
目标 POST 服务是未经身份验证的 HTTPS。尝试通过 Curl 或通过 Informatica 运行我的 POST 请求时,这两种方法都出现 SSL 握手失败。
例如:
curl -X POST -F 'file=@filename.dat' https://url
我已经能够使用 Postman 使其正常工作,所以我知道该服务有效。根据网络安全,在此环境中禁用 SSL。是我不走运,还是有办法让它在没有 SSL 的情况下工作?
遇到的具体错误: curl :(35)错误:14077410:SSL例程:SSL23_GET_SERVER_HELLO:sslv3警报握手失败
最佳答案
默认情况下,建立 HTTPS URL 连接的客户端将检查 SSL 证书的有效性 - 否则,使用 SSL 有什么意义?
在您的情况下,您说的是“假装使用 HTTPS 但实际上忽略了证书”,因为它无效,或者您仍在获得证书,或者您处于开发阶段(我希望后者是真的,并且在需要时获取或创建有效的服务器证书)。
但是 curl
不知道。假设您要求它与 HTTPS 端点建立连接 - 因此它将尝试验证证书 - 在您的情况下,这可能是失败的根源。
尝试 curl -k -X POST -F 'file=@filename.dat' https://url
从联机帮助页:
-k, --insecure (TLS) By default, every SSL connection curl makes is verified to be secure. This option allows curl to proceed and operate even for server connections otherwise considered insecure. The server connection is verified by making sure the server's certificate contains the right name and verifies successfully using the cert store. See this online resource for further details: https://curl.haxx.se/docs/sslcerts.html See also --proxy-insecure and --cacert.
关于使用 Curl 将文件发布到 Web 服务的 SSL 握手错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46711705/