Skip to content

payload error #7

@carlhung

Description

@carlhung

Hey,
sorry to disturb you.
I installed swift complier of version 3.1.1 on Ubuntu in order to run the code.
certificate is good although I found some problem. also, installed http2, etc. all the components I need.
now, I can successfully use the certificate.
but I encountered another error message from curl.

there is the code I used:
// the token is work, i used other application to test the token.
let token = "8fcf2f3a21102db657da053870781bb4164bce650ab8afd77de24ce52f796848"
let push = APNS(withCerts: APNSCertificate(certPath: "/home/carl/swift/time/pem/crt.pem",
keyPath: "/home/carl/swift/time/pem/key.pem
)
)
let payload = APNSPayload(withText: "Test")
push.send(payload: payload, to: token)

I got following error:

  • Trying 17.188.166.27...
  • Connected to api.development.push.apple.com (17.188.166.27) 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
  • 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: Jun 19 01:49:43 2015 GMT
  • expire date: Jul 18 01:49:43 2017 GMT
  • subjectAltName: api.development.push.apple.com matched
  • 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 0x7f2254021530)

POST /3/device/8fcf2f3a21102db657da053870781bb4164bce650ab8afd77de24ce52f796848 HTTP/1.1
Host: api.development.push.apple.com
Accept: application/json
Content-Type: application/json
apns-priority: 10
apns-expiration: 0
Content-Length: 6

< HTTP/2.0 200
HTTP/2.0 200
< apns-id:F6303094-AA99-B6EF-D603-03A751EB391C
apns-id:F6303094-AA99-B6EF-D603-03A751EB391C

<

  • Connection #0 to host api.development.push.apple.com left intact
    ret = CURLcode(rawValue: 0)

------------------------------the error message can be different, some time:-----------------------
...
Content-Length: 0

< HTTP/2.0 400
HTTP/2.0 400
< apns-id:0D66D5A3-2909-D13A-F1DD-0F9234DA883F
apns-id:0D66D5A3-2909-D13A-F1DD-0F9234DA883F

  • HTTP error before end of send, stop sending
    <
    {"reason":"PayloadEmpty"}* Closing connection 0
    ret = CURLcode(rawValue: 0)

-------------------------------------sometime:---------------------------------------------------
Content-Length: 3

< HTTP/2.0 200
HTTP/2.0 200
< apns-id:9C2EC37B-4DEF-ACFF-3C20-A3C491C6A3BC
apns-id:9C2EC37B-4DEF-ACFF-3C20-A3C491C6A3BC

<

  • Connection #0 to host api.development.push.apple.com left intact
    ret = CURLcode(rawValue: 0)

but the way, I found a bug if the file names of the key and certificate have more than two dots like:
xxx.xxx.pem // that causes unable to open the file.
xxx.pem // that is work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions