【问题标题】:Connecting to Apple's APNS using cURL with HTTP\2 support via nghttp2通过 nghttp2 使用带有 HTTP\2 支持的 cURL 连接到 Apple 的 APNS
【发布时间】:2016-05-26 18:27:48
【问题描述】:

我尝试通过关注this tutorial 来编译支持 HTTP/2 的 cURL。我正在使用Docker,我的应用程序基于使用Debian 的official PHP Docker image,尽管我在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 最近重新推出的 APNS Provider API 时开始出现问题,该 APNS Provider API 现在在 HTTP/2 上运行。

我已经通过 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 的服务,以及需要采取什么措施来解决这种情况。

任何帮助都会非常感谢

【问题讨论】:

  • 这个Q可能更适合相关网站apple.stackexchange.com(问不同)。考虑使用 Q 底部的flag 链接,并要求版主将其移到那里。请不要在 2 个不同的网站上发布相同的 Q。谢谢,祝你好运。

标签: linux curl docker apple-push-notifications nghttp2


【解决方案1】:

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

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

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2021-05-21
      • 1970-01-01
      • 2017-08-07
      • 2021-11-22
      • 2018-12-19
      • 2020-09-29
      • 2021-12-24
      • 2020-06-17
      • 2015-02-13
      相关资源
      最近更新 更多