How to generate the Apple certificate properly?

71 Views Asked by At

I've followed the tutorial on this website but if I want to save the results i get a message that prevents me from saving the results:

1 error prohibited this sender from being saved:

  • APNS certificate or private key is not valid

But why do I get this error? I've tried a couple of methods, placing it with -----BEGIN CERTIFICATE----- and placing it without it, but nothing works. I've created a couple of certificates but each one is false according too the error.

Have I forgot something to do?

1

There are 1 best solutions below

1
On

placing it with -----BEGIN CERTIFICATE----- and placing it without it, but nothing works.

You must copy and paste the whole content of the files, including -----BEGIN CERTIFICATE----- and ----- END CERTIFICATE-----.

But why do I get this error?

You have probably done an error in one of the steps: that error means that the certificates are not valid. They are not valid in general (e.g. malformed, etc.): this is not something specific related to push notifications, APNs or Pushpad.

If you know Ruby, you can see what is the exception raised by that certificates by running the following snippet:

private_key = OpenSSL::PKey.read apns_private_key
certificate = OpenSSL::X509::Certificate.new apns_certificate
pkcs12 = OpenSSL::PKCS12.create(nil, nil, private_key, certificate)
pkcs12.to_der

Otherwise contact [email protected] and attach your cert/private key so that I can try to help.