Firebase: Cannot upload production APNs certificate

Robbie Lewis picture Robbie Lewis · Jun 13, 2016 · Viewed 30.8k times · Source

I am currently testing an app in TestFlight and need a production APNs certificate in order to test Notifications in Firebase.

I have followed all of the steps in this video and successfully configured the development APNs certificate: https://www.youtube.com/watch?v=LBw5tuTvKd4

I've also checked that my steps following the Firebase support guide. Although I note that the Apple Developer site has changed slightly since this guide was written: https://firebase.google.com/docs/cloud-messaging/ios/certs#configure_an_app_id_for_push_notifications

I have generated a production APNs certificate at developer.apple.com using the same method as the development certificate but when I try to upload the .p12 file to Firebase, it gives me the following error:

"The certificate environment did not match. Ensure that you got the right development or production APNS certificate."

I'm definitely uploading a .p12 generated from a production APNS certificate, is there something else I need to do for a production certificate?

Answer

Robbie Lewis picture Robbie Lewis · Jun 13, 2016

Solved. The mistake I was making was that I was exporting the "private key" part of the certificate in Keychain Access instead of the "certificate" part. As soon as I re exported the .p12 using the correct row in the list - it worked.

Images to illustrate below credit iOS

Don't select & create private key for Production certificate

Correct method:

Directly select certificate & create production certificate