gnutls
尽管 wget 可以正常获取页面,但为什么无法联系有问题的网站?
$ gnutls-cli https://site.com/login.php --insecure --print-cert < /dev/null > cert
WARNING: gnome-keyring:: couldn't connect to: /run/user/dotancohen/keyring-Ekufyf/pkcs11: No such file or directory
Cannot resolve https://site.com/login.php:443: Name or service not known
$ wget https://site.com/login.php
--2013-01-23 19:07:57-- https://site.com/login.php
Resolving site.com (site.com)... 72.1.2.3
Connecting to site.com (site.com)|72.1.2.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6581 (6.4K) [text/html]
Saving to: `login.php'
100%[=============================================>] 6,581 --.-K/s in 0s
2013-01-23 19:07:58 (47.8 MB/s) - `login.php' saved [6581/6581]
$
答案1
正如 Stephane Chazelas 在他们的评论中指出的那样,问题在于您提供的是 URL 而不是主机名。gnutls-cli
只是一个 SSL/TLS 客户端,对 URI 或更高级别的协议(例如 HTTP)一无所知;它期望只获得一个要连接的主机名(或 IP 地址)。