无法解析主机:com.domainname.appname:如何修复?
Could not resolve host: com.domainname.appname: How To Fix?
基于Sending Push Notifications Using Command-Line Tools,我在创建新的 CSR、App ID 并从 Apple 获取新的提供商证书后设置了以下 shell 变量:
CERTIFICATE_FILE_NAME=/Users/developer/desktop/aps.cer
CERTIFICATE_KEY_FILE_NAME=/Users/developer/desktop/PushChatKey.p12
TOPIC=com.domainname.appname
DEVICE_TOKEN=af59ba83a511f21f343df63ebd1bcd32225878e7d9401a4e933a3caf0cf55a63
APNS_HOST_NAME=api.sandbox.push.apple.com
我输入以下终端命令来发送测试推送通知:
curl -v --header apns-topic: com.domainname.appname --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"test"}}' --http2 https://api.sandbox.push.apple.com/3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1
这是最终的终端输出:
curl -v --header apns-topic: com.domainname.appname --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"test"}}' --http2 https://api.sandbox.push.apple.com/3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1
* Could not resolve host: com.domainname.appname
* Closing connection 0
curl: (6) Could not resolve host: com.domainname.appname
* Could not resolve host: alert
* Closing connection 1
curl: (6) Could not resolve host: alert
* Trying 17.188.138.71...
* TCP_NODELAY set
* Connected to api.sandbox.push.apple.com (17.188.138.71) port 443 (#2)
* ALPN, offering h2
* ALPN, offering http/1.1
Enter PEM pass phrase:
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* 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, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (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.development.push.apple.com; OU=management:idms.group.533599; O=Apple Inc.; ST=California; C=US
* start date: Feb 8 21:41:22 2021 GMT
* expire date: Mar 10 21:41:22 2022 GMT
* subjectAltName: host "api.sandbox.push.apple.com" matched cert's "api.sandbox.push.apple.com"
* issuer: CN=Apple Public Server RSA CA 12 - G1; O=Apple Inc.; ST=California; C=US
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fe70780d600)
> POST /3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1 HTTP/2
> Host: api.sandbox.push.apple.com
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 24
> Content-Type: application/x-www-form-urlencoded
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 1000)!
* We are completely uploaded and fine
< HTTP/2 400
< apns-id: E9EC6D23-7E07-BA0A-B574-F478271AE803
<
* Connection #2 to host api.sandbox.push.apple.com left intact
{"reason":"MissingTopic"}* Closing connection 2
我该如何解决这个问题?
这部分有问题:
--header apns-topic: com.domainname.appname
请调整为:
- 注意在
--header
参数的开头和结尾使用单引号 ''
apns-topic: com.domainname.appname
--header 'apns-topic: com.domainname.appname'
curl -v --header 'apns-topic: com.domainname.appname' --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"test"}}' --http2 https://api.sandbox.push.apple.com/3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1
基于Sending Push Notifications Using Command-Line Tools,我在创建新的 CSR、App ID 并从 Apple 获取新的提供商证书后设置了以下 shell 变量:
CERTIFICATE_FILE_NAME=/Users/developer/desktop/aps.cer
CERTIFICATE_KEY_FILE_NAME=/Users/developer/desktop/PushChatKey.p12
TOPIC=com.domainname.appname
DEVICE_TOKEN=af59ba83a511f21f343df63ebd1bcd32225878e7d9401a4e933a3caf0cf55a63
APNS_HOST_NAME=api.sandbox.push.apple.com
我输入以下终端命令来发送测试推送通知:
curl -v --header apns-topic: com.domainname.appname --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"test"}}' --http2 https://api.sandbox.push.apple.com/3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1
这是最终的终端输出:
curl -v --header apns-topic: com.domainname.appname --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"test"}}' --http2 https://api.sandbox.push.apple.com/3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1
* Could not resolve host: com.domainname.appname
* Closing connection 0
curl: (6) Could not resolve host: com.domainname.appname
* Could not resolve host: alert
* Closing connection 1
curl: (6) Could not resolve host: alert
* Trying 17.188.138.71...
* TCP_NODELAY set
* Connected to api.sandbox.push.apple.com (17.188.138.71) port 443 (#2)
* ALPN, offering h2
* ALPN, offering http/1.1
Enter PEM pass phrase:
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* 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, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (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.development.push.apple.com; OU=management:idms.group.533599; O=Apple Inc.; ST=California; C=US
* start date: Feb 8 21:41:22 2021 GMT
* expire date: Mar 10 21:41:22 2022 GMT
* subjectAltName: host "api.sandbox.push.apple.com" matched cert's "api.sandbox.push.apple.com"
* issuer: CN=Apple Public Server RSA CA 12 - G1; O=Apple Inc.; ST=California; C=US
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fe70780d600)
> POST /3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1 HTTP/2
> Host: api.sandbox.push.apple.com
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 24
> Content-Type: application/x-www-form-urlencoded
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 1000)!
* We are completely uploaded and fine
< HTTP/2 400
< apns-id: E9EC6D23-7E07-BA0A-B574-F478271AE803
<
* Connection #2 to host api.sandbox.push.apple.com left intact
{"reason":"MissingTopic"}* Closing connection 2
我该如何解决这个问题?
这部分有问题:
--header apns-topic: com.domainname.appname
请调整为:
- 注意在
--header
参数的开头和结尾使用单引号''
apns-topic: com.domainname.appname
--header 'apns-topic: com.domainname.appname'
curl -v --header 'apns-topic: com.domainname.appname' --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"test"}}' --http2 https://api.sandbox.push.apple.com/3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1