【发布时间】:2020-05-30 07:05:19
【问题描述】:
我在使用自签名 SSL 证书和 curl 时遇到问题。
服务器是 lighttpd。 HTTPS 工作正常:
$ curl https://192.168.144.1/zxc -k
HELLO
但是从 HTTP 重定向失败:
curl http://192.168.144.1:81/zxc -kvL
* Trying 192.168.144.1...
* TCP_NODELAY set
* Connected to 192.168.144.1 (192.168.144.1) port 81 (#0)
> GET /zxc HTTP/1.1
> Host: 192.168.144.1:81
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Location: https://192.168.144.1:81/zxc
< Content-Length: 0
< Date: Sat, 30 May 2020 06:59:57 GMT
< Server: lighttpd/1.4.48
<
* Connection #0 to host 192.168.144.1 left intact
* Issue another request to this URL: 'https://192.168.144.1:81/zxc'
* Hostname 192.168.144.1 was found in DNS cache
* Trying 192.168.144.1...
* TCP_NODELAY set
* Connected to 192.168.144.1 (192.168.144.1) port 81 (#1)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
........... HERE IT STACKS FOR A MINUTE ....................
* LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 192.168.144.1:81
* stopped the pause stream!
* Closing connection 1
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 192.168.144.1:81
我在这里找到了一个可能的解决方案https://stackoverflow.com/a/44494250/3743145:CURLOPT_SSL_VERIFYPEER=false。如何将其传递给 CURL CLI?
【问题讨论】:
-
您使用的是 Mac 吗?我看到 /etc/ssl/cert.pem 中的证书今天过期了。我在我的 Mojave 电脑上遇到了同样的问题,我不知道如何更新它,也不知道如何更新它?我的 Catalina 电脑有一个更新的证书,我想知道是否可以直接复制它。