GUI 浏览器(例如 FIrefox)可以打开 URL,但 curl 超时

GUI 浏览器(例如 FIrefox)可以打开 URL,但 curl 超时

当我执行时,问题就出现了apt-get 更新尝试更新 gitlab-ce 存储库时失败,出现以下错误(尽管它在大约一个月前才正常工作):

W: Failed to fetch https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/xenial/InRelease  Operation timed out after 0 milliseconds with 0 out of 0 bytes received

然后我尝试卷曲看到相同的 URL 并且再次失败并显示以下消息:

curl -vvv https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/xenial/InRelease
*   Trying 54.153.54.194...
* Connected to packages.gitlab.com (54.153.54.194) port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 600 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* Operation timed out after 0 milliseconds with 0 out of 0 bytes received
* Closing connection 0
curl: (28) Operation timed out after 0 milliseconds with 0 out of 0 bytes received

但有趣的是,当我尝试使用同一系统的 Firefox 打开相同的 URL 时,它就可以正常工作,尽管它会重定向到另一个 URL,但它可以正常工作。重定向目标如下

https://packages-gitlab-com.s3-accelerate.amazonaws.com/7/8/ubuntu/dists/xenial/InRelease?AWSAccessKeyId=AKIAJ74R7IHMTQVGFCEA&Signature=Dwkp3C7Q2mXBtiPCUiFZhoGzWF8%3D&Expires=1529707236

我该怎么做才能修复这个问题,并apt-get 更新重新工作。


的结果卷曲-V

curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets

答案1

我不确定您为什么会超时。奇怪的是,tcp 连接成功了,但 TLS 的 ALPN 扩展是导致超时的原因。您没有收到 ALPN 响应。也许是瞬态的?您也可以尝试添加该选项--no-alpn。无论如何,为了让 curl 检索您想要的文件,您将需要-L遵循重定向的选项。以下对我有用:curl -vvvL https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/xenial/InRelease

答案2

您可能遇到了服务器过载问题。我刚刚尝试了您的 curl 命令,结果显示正常:

nosklo@onyx:/tmp$ curl -vvv https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/xenial/InRelease
*   Trying 54.153.54.194...
* TCP_NODELAY set
* Connected to packages.gitlab.com (54.153.54.194) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: OU=Domain Control Validated; OU=PositiveSSL; CN=packages.gitlab.com
*  start date: Feb 21 00:00:00 2018 GMT
*  expire date: Feb 26 23:59:59 2019 GMT
*  subjectAltName: host "packages.gitlab.com" matched cert's "packages.gitlab.com"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO RSA Domain Validation Secure Server CA
*  SSL certificate verify ok.
> GET /gitlab/gitlab-ce/ubuntu/dists/xenial/InRelease HTTP/1.1
> Host: packages.gitlab.com
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 302 Found
< Server: nginx
< Date: Fri, 22 Jun 2018 22:43:09 GMT
< Content-Type: text/html;charset=utf-8
< Content-Length: 0
< Connection: keep-alive
< Location: https://packages-gitlab-com.s3-accelerate.amazonaws.com/7/8/ubuntu/dists/xenial/InRelease?AWSAccessKeyId=AKIAJ74R7IHMTQVGFCEA&Signature=fTf126FjXAZAHkuzf2LKKLV5O5s%3D&Expires=1529707689
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< Cache-Control: no-cache
< X-Request-Id: 62f491a7-9ae3-45c1-bb09-21ccfd83c855
< X-Runtime: 0.005186
< Strict-Transport-Security: max-age=31536000
< X-Frame-Options: DENY
< 
* Connection #0 to host packages.gitlab.com left intact

如果您仍然有问题,请向我们展示结果curl -V

相关内容