2

我尝试按照本教程来编译支持 HTTP/2 的 cURL 。我正在使用Docker,我的应用程序基于使用 Debian 的官方 PHP Docker 映像,尽管我在Vagrant VM 中运行的 Ubuntu 机器上也遇到了同样的问题。

起初似乎没有问题。事实上,跑步curl --version显示了我所期望的一切:

curl 7.47.1 (x86_64-pc-linux-gnu) libcurl/7.47.1 OpenSSL/1.0.1k zlib/1.2.8 libidn/1.29 libssh2/1.4.3 nghttp2/1.7.1 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets 

另外,我可以很好地连接到https://nghttp2.org :

curl --http2 -I https://nghttp2.org
HTTP/2.0 200
date:Mon, 15 Feb 2016 18:02:34 GMT
content-type:text/html
content-length:6680
last-modified:Thu, 11 Feb 2016 14:29:49 GMT
etag:"56bc9add-1a18"
link:</stylesheets/screen.css>; rel=preload; as=stylesheet
accept-ranges:bytes
x-backend-header-rtt:0.000581
server:nghttpx nghttp2/1.8.0-DEV
via:1.1 nghttpx
strict-transport-security:max-age=31536000
x-frame-options:SAMEORIGIN
x-xss-protection:1; mode=block
x-content-type-options:nosniff

当尝试连接到 Apple 最近重新推出的现在在 HTTP/2 上运行的APNS Provider API时,问题就开始了。

我已经通过 Homebrew 在我的 Mac 上安装了 curl(使用--with-nghttp2),我可以获得以下(预期的)响应:

curl -d 'Hello' --http2 https://api.push.apple.com/3/device/test
{"reason":"Forbidden"}

但是,如果我尝试从我的 Docker 映像中运行相同的命令,我会得到:

curl -d 'Hello' --http2 https://api.push.apple.com/3/device/test
?@@?HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 504f5354202f332f6465766963652f746573742048545450

我不确定为什么这个问题似乎特定于 Apple 的服务,以及需要采取什么措施来纠正这种情况。

任何帮助将不胜感激!

4

2 回答 2

0

这里的问题是,OpenSSL/1.0.1k 不附带 ALPN 协议。

Apple 需要它,而https://nghttp2.org对 NPN 很满意。

所以要解决这个问题,让 OpenSSL/1.0.2 工作,一切就绪。

于 2016-06-09T20:50:28.197 回答
0

对于以后看到这个的人,我最终解决了这个问题,答案在Server Fault上。

于 2016-03-05T16:37:52.837 回答