Apple推送通知curl:(16)HTTP2帧层错误

问题描述 投票:0回答:2

我确实在 ubuntu 终端上运行此命令

curl --verbose -H 'apns-topic: Skios.TripBruCACT' --header "Content-Type: application/json" --data '{"aps":{"content-available":1,"alert": “嗨”,“声音”:“默认”}}' --cert /home/mohamed/Downloads/Prod2.pem:a1B23 --http2 'https://api.push.apple.com/3/device/ 19297dba97212ac6fd16b9cd50f2d86629aed0e49576b2b52ed05086087da802'

但它返回 curl: (16) HTTP2 框架层错误

这是全部结果

*   Trying 17.188.145.163...
* Connected to api.push.apple.com (17.188.145.163) port 443 (#0)
* 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/certs/ca-certificates.crt CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* 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, Request CERT (13):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS handshake, CERT verify (15):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=api.push.apple.com; OU=management:idms.group.533599; O=Apple Inc.; ST=California; C=US
*  start date: Aug 28 19:03:46 2015 GMT
*  expire date: Sep 26 19:03:46 2017 GMT
*  subjectAltName: host "api.push.apple.com" matched cert's "api.push.apple.com"
*  issuer: CN=Apple IST CA 2 - G1; OU=Certification Authority; O=Apple Inc.; C=US
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* TCP_NODELAY set
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0xdb69a0)
> POST /3/device/19297dba97212ac6fd16b9cd50f2d86629aed0e49576b2b52ed05086087da802 HTTP/1.1
> Host: api.push.apple.com
> User-Agent: curl/7.50.0
> Accept: */*
> apns-topic: Skios.TripBruCACT
> Content-Type: application/json
> Content-Length: 62
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* We are completely uploaded and fine
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):
curl: (16) Error in the HTTP2 framing layer

但是我在最后一行遇到了这个错误

curl: (16) HTTP2 成帧层错误

curl push-notification apple-push-notifications
2个回答
0
投票

在 2024 年,当处于错误模式(沙盒与生产)或在卷曲参数中混合使用沙盒和生产时,就会发生这种情况。这很可能不是几年前存在的卷曲问题。

生成证书时,同时生成两个证书 - Sandbox 和 Sandbox + Production。 Apple 将生成“沙盒”作为“开发”,这两个术语可以互换使用 - 您可能会认为,因为您不在沙盒中,所以默认处于包含开发的生产路径中。

创建两个curl命令,一个用于沙箱,一个用于生产。除了证书之外,您还需要将沙箱中的http引用更改为“https://api.sandbox.push.apple.com”。

上面最有可能发生的情况是,您从 xcode(沙箱/开发)生成应用程序,而不是使用 http 参考进行 testflight(生产),因此它会为您提供最有可能是特定问题的模糊错误。

API 参考发生变化,因此请查看 Apple API 上的最新信息。考虑一下您的构建来自哪里 - xcode 还是 testflight/app store,然后这将决定您是否使用沙箱或生产。


-1
投票

我了解您正在尝试使用 .pem 文件测试推送通知。请尝试以下步骤。

不要提供证书路径,而是将终端的目录更改为 .pem 文件包含的文件夹。

然后,运行以下命令,

对于开发 APNS:

curl -d '{"aps":{"alert":"hi","sound":"default"}}' --cert yourpem.pem: -H "apns-topic: yourbundleID" - -http2 https://api.development.push.apple.com/3/device/yourdevicetoken

对于生产 APNS:

curl -d '{"aps":{"alert":"hi","sound":"default"}}' --cert yourpem.pem: -H "apns-topic: yourbundleID" - -http2 https://api.push.apple.com/3/device/yourdevicetoken

© www.soinside.com 2019 - 2024. All rights reserved.