112

With the recent up gradation of the Apple developer accounts, I am facing a difficulty that while trying to create the push notification certificates, it is providing me with (.p8) certificate instead of APNs ones which can be exported to (.p12).

Firebase console only accepts (.p12) certificates so how I can get that out from these new (.p8) certificates.

Krunal
  • 77,632
  • 48
  • 245
  • 261
Subso
  • 1,413
  • 2
  • 10
  • 16

8 Answers8

72

I was able to do this by selecting "All" located under the "Keys" header from the left column

enter image description here

Then I clicked the plus button in the top right corner to add a new key

enter image description here

Enter a name for your key and check "APNs"

enter image description here

Then scroll down and select Continue. You will then be brought to a screen presenting you with the option to download your .p8 now or later. In my case, I was presented with a warning that it could only be downloaded once so keep the file safe.

fedorqui
  • 275,237
  • 103
  • 548
  • 598
John Idasetima
  • 1,053
  • 9
  • 9
  • 6
    Thanks, the developer account has updated. There is no more `APNs Auth Keys` into `Certificates` – Djiggy Jul 06 '17 at 09:28
  • Thanks, you saved me! – sioesi Mar 23 '18 at 05:45
  • @John can you help me out, I've been stuck for the past few days. I can't get fcm working.. https://stackoverflow.com/questions/50292269 – bibscy May 13 '18 at 22:21
  • They key may not expire, but "provisioning profiles" do. Are they still required to send push notifications, or can we get rid of them safely? Thanks – andreszs Jun 11 '18 at 22:16
  • 6
    @John Idasetima I'm confused how this answer the question - which was Firebase only accepts p12 but the new key is p8. Your answer just says how to download the key *as a p8*. Are you saying Firebase accepts the p8 as well as the p12? – Gruntcakes Jul 11 '19 at 21:47
32

Apple have recently made new changes in APNs and now apple insist us to use "Token Based Authentication" instead of the traditional ways which we are using for push notification.

So does not need to worry about their expiration and this p8 certificates are for both development and production so again no need to generate 2 separate certificate for each mode.

To generate p8 just go to your developer account and select this option "Apple Push Notification Authentication Key (Sandbox & Production)"

enter image description here

Then will generate directly p8 file.

I hope this will solve your issue.

Read this new APNs changes from apple: https://developer.apple.com/videos/play/wwdc2016/724/

Also you can read this: https://developer.apple.com/library/prerelease/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/APNsProviderAPI.html

Hardik Shah
  • 1,683
  • 1
  • 11
  • 20
  • 2
    Can we convert .p8 to .PEM type? – Dimple Shah Sep 28 '16 at 14:08
  • Any platform which required .p8 does not need .PEM file, if it is still required then you need to make it separate – Hardik Shah Sep 28 '16 at 18:11
  • 2
    I think Firebase does not yet support the use of APNs Auth Keys (.p8). But at the same time, it is easier to just do it from your own server now. – Andre Cytryn Oct 20 '16 at 23:33
  • 2
    Thanks - I'm not using firebase, but I found this answer most helpful for moving from .pem to .p8 files. I also found this step-by-step guide from Apple to be invaluable; it was the next step for me after following your answer : https://eladnava.com/send-push-notifications-to-ios-devices-using-xcode-8-and-swift-3/ – kris Oct 21 '16 at 08:14
  • 5
    @HardikShah This option "Apple Push Notification Authentication Key (Sandbox & Production)" is not available. why? – Balasubramanian Jun 19 '17 at 10:07
  • @HardikShah is there an option to delete previous Keys created in developer.apple.com? I only see a + button, but no - button , or delete.. – bibscy May 11 '18 at 10:29
  • @HardikShah any idea what I am doing wrong? I can't get fcm to work. Please red my question https://stackoverflow.com/questions/50292269 – bibscy May 13 '18 at 22:22
  • @bibscy Have you tested to send push notification from the firebase console itself? What are you getting? – Hardik Shah May 14 '18 at 08:55
  • @HardikShah I tried to send push notifications from firebase console itself and I get error `Invalid APNs certificate. Check the certificate in settings`. Once I download the p8 file from developer.apple.com, the only thing I did was to upload it in firebase console in box that reads APNs Authentication Key . Do I have to double click or do anything else with the p8 file on my Mac? – bibscy May 14 '18 at 09:00
  • @bibscy Steps in your questions seems perfectly fine. Just double check that the APP id and bundle ID is proper while adding p8. Actually, it is pretty straightforward process nothing fancy but if you getting trouble then I recommend you that please verify 2 things and if still not work then create a fresh test project and try to do that. Sometimes when we try hard nothing works so in that case it is better to fresh start. – Hardik Shah May 14 '18 at 09:05
  • I know this question is not directly related but I am getting: `Exception: TooManyProviderTokenUpdates after updating my certificates to .p8` [https://stackoverflow.com/questions/57911697/apns2-exception-toomanyprovidertokenupdates] I am using apns2 library. Can you answer my question? – Anant Sep 12 '19 at 17:39
  • This flow generates a .cer file not a .p8 file. Does the .cer need to be converted somehow? – N S May 27 '20 at 08:28
28

May 2021 - Generating .p8 file instead of .cer file

The issue that I had was I couldn't find the way to create the .p8 file and all methods gave me .cer file instead.

  1. Head to your Apple developer account
  2. Go to the keys section and click on the plus button (or click here):

⚠️ It is very important to select the keys section and NOT the certificate or identifiers. otherwise you will get the .cer file at last ‍♂️

Keys section

  1. Select the Apple push notification service: Options

⚠️ Note that since it is very powerful certificate, it is very limited and you can not have much of these. So if you already created one, you will face something like this image and you should use that file or just revoke the old one.

  1. Download the.p8 file and secure it somewhere.
Mojtaba Hosseini
  • 95,414
  • 31
  • 268
  • 278
  • 1
    This is it, thanks!! The answer, after 2 hours of trying to convert .cer to .pem or .p12 and to .p8, was pretty simple. – matsbauer Aug 06 '21 at 07:38
21

So, After taking a while I figured out that the old push certificate generating service also exists.

You get two options:

  • Apple Push Notification Authentication Key (Sandbox & Production)
  • Apple Push Notification service SSL (Sandbox & Production)

Those who want to achieve the old style .p12 certificate can get it from second option. I have not used the first option yet as most of the third-party push notification service providers still need the .p12 format certificate.

Sample image of the push notification service

KlimczakM
  • 12,576
  • 11
  • 64
  • 83
Subso
  • 1,413
  • 2
  • 10
  • 16
19

Firebase console is now accepting .p8 file, in fact, it's recommending to upload .p8 file.

You can see in below-attached screenshot

dharmendra vaishnav
  • 1,851
  • 2
  • 17
  • 23
  • 3
    Please correct me if wrong, but that *App ID prefix* is actually the *Team ID* found at the [Membership Information](https://developer.apple.com/account/#/membership/) page, right? Because the tooltip clearly says it's located at the Membership Information page, and it even links to it. – andreszs Jun 11 '18 at 22:34
  • 2
    What is the "Key ID" referenced there? Consider me a noob. – Umair Ahmed May 21 '19 at 15:51
  • 2
    @UmairAhmed The string of the device token you receive when you ask to register for push notifications. – Huy-Anh Hoang Jun 07 '19 at 17:43
  • 2
    No. It's not the device token. It's the string after the underscore in the name of the .p8 file. Like this ---> AuthKey_A5HG8NYIFC.p8. Also you can see it after creating the key in the Key menu in Certificates, Identifiers & Profiles section in Apple Developer Website. – Somoy Das Gupta Sep 11 '19 at 14:57
9

Follow these steps:

1. Generate an APNs Auth Key
Open the APNs Auth Key page in your Developer Center and click the + button to create a new APNs Auth Key.

enter image description here

In the next page, select Apple Push Notification Authentication Key (Sandbox & Production) and click Continue at the bottom of the page.

enter image description here

Apple will then generate a .p8 key file containing your APNs Auth Key.

enter image description here

Download the .p8 key file to your computer and save it for later. Also, be sure to write down the Key ID somewhere, as you'll need it later when connecting to APNs.

2. Send Push Notifications

Ref: APNS (Configure push notifications)

Important: Save a back up of your key in a secure place. It will not be presented again and cannot be retrieved later.

Krunal
  • 77,632
  • 48
  • 245
  • 261
  • 4
    APN's Auth Key does not exist in my developer portal. Does anyone know why? – ckim16 Jun 21 '17 at 23:24
  • @ckim16 - It can be generated once and won't be visible (removes APNS Auth key options) again. Here is reference to your query (help.apple.com/xcode/mac/current/#/…). If you have generated it previously, then it won't be visible to you again. – Krunal Jun 22 '17 at 01:17
  • I wonder if your link only works for people who paid to have an Apple Developer account. For me, it redirects to https://developer.apple.com/account/#/welcome – Ryan Apr 15 '18 at 19:22
  • @Krunal I've been stuck for the past few days trying to connect to firebase cloud messaging using the .p8 file and I can't get it to work. Could please have a look at my questions https://stackoverflow.com/questions/50292269 – bibscy May 13 '18 at 22:25
  • It doesn't download a p8 file for me :-| – Oliver Dixon Sep 22 '18 at 16:35
  • Double clicked - it is opened in text editor instead. How to return the default behaviour you described? – Vyachaslav Gerchicov Mar 05 '20 at 10:21
  • hey @Krunal, thanks for the answer, I've worked for make it work but when I get even documentation for FCM it did not work when I upload it p8 file (APNS Key). I had to upload a p12 file too like the old style. I cannot find the problem – eemrah Apr 26 '21 at 11:40
6

You can create the .p8 file for it in https://developer.apple.com/account/

Then go to Certificates, Identifiers & Profiles > Keys > add

apple_key

Select Apple Push Notification service (APNs), put a Key Name (whatever).

Then click on "continue", after "register" and you get it and you can download it.

Dody
  • 608
  • 7
  • 19
4

When you upload your p8 file in Firebase, in the box that reads App ID Prefix(required) , you should enter your team ID. You can get it from https://developer.apple.com/account/#/membership and copy/paste the Team ID as shown below.

enter image description here

bibscy
  • 2,598
  • 4
  • 34
  • 82
  • 2
    Thank you, I was looking for that exactly. The label is clearly wrong in FCM console and no one has noticed that error, even a year after. – andreszs Jun 11 '18 at 22:36