GCM certificate configuration not working or iOS - ios

I am facing one issue when I am trying to confiure the GCM and getting configuration file. When I am trying to upload the production certificate over the GCM portal it says "Bundle Id in certificate doesn't match with Bundle Id you entered". I verified already for the same. Still no joy. Anyone help plz.

For my case, I have to export a cer not a private key.

I had the same problem but for different reason. It turns out that the .p12 file has something wrong. If I export .p12 file from Keychain Access by selecting both certificate and key and export 2 items together, it doesn't work. I need to export the certificate and key separately and merge them later. Use terminal to merge two files:
cat cert.p12 key.p12 > cert_merged.p12

I have been getting same exact problem in Firebase (FCM).
The only solution which has worked for me, which I found by hit and trial is while exporting the Cert as the P12, only select the Cert but don't select the Key.
You will still be able to export only the Cert (without the key) as a P12 file and set the password in a similar way.
Now uploading this P12 file with the provided password works for me.
Make sure to export only the certificate not the key... by clicking on the triangular/caret dropdown icon and deselecting the key

I tried it with both Development and Production .p12, both worked for me.
You need to make sure you generate a correct .cer certificate file from your Bundle ID, and need to make sure you export the correct .p12 file from your Keychain Access. You can view the sample steps in this page.
You need to make sure the iOS Bundle ID you input in the GCM portal.
(I use mine com.ziyang.samples.quickstart.gcm)
matches the Bundle ID in your Apple Developer Portal.
(I use mine com.ziyang.samples.quickstart.gcm)
If I miss typed the iOS Bundle ID in the GCM portal, it will show the below error:

Make sure you're using your APNS certificate and not your regular development or production certificate. Just spent an hour on this until I realised my mistake!

if you sure you set the right bundle id You can solve it by:-
1-Export only private key as p12.
2-Export only CERT as p12.
3-Export CERT with private key as p12.
and try one by one to solve this issue

Please select the Certificate instead of the key in the Keychain Access while exporting it to .p12.

A Password is Required when exporting the development certificate. The Development certificate would not upload with any of these suggestions until I added a password. I was, however, able to upload the Release certificate without a password. I also used the suggestion of #Sur Max to only export the certificate and not the key.

Related

Fail to upload iOS APNs Certificate on Firebase

I can't upload my production APNs Certicate on Firebase. There was an error reading your certificate.
I can't find out the cause of this error.
You should select only the certificate and don't select the private key . See this screenshot
I experienced the same issue before due to not proper "Certificate Signing Request". You may miss the Common name when you create a "Certificate Signing Request" or you may mentioned any other mails that didn't include in your xcode as developer Account.
Please try to put a common name and do the process again to create a new APN Certificate.
I think you make some mistake's to create the certificate. Follow this link to create certificate correctly and try.
In my case I have faced this issue because I was exported 2 items Apple Development Push Services along with private key, and uploaded .p12 file to firebase. Then it said there was an error reading your certificate.
So the solution is don't export private key along with Apple Development Push Services item. Now generated .p12 file uploaded in Firebase. And the upload was successful.
Hope it will help to someone.

Firebase: Cannot upload production APNs certificate

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?
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
Correct method:
try this
make .csr file and download cert from developer.apple.com
while exporting select private key and certificate both at a same time and export to .p12 with any passphase.
upload tht .p12 file on firebase console.
Thanks
Don't select private ket in key chain, directly select certificate and create production certificate.
1) Don't select private ket in key chain.
2) Directly select certificate and create production certificate
I am facing the same problem and i have tried all above mentioned solution but nothing works for me than i delete certificate from keychain access and again download certificate and install it than export and try to upload it. It works for me.
When I tried the solution suggested here, nothing works (This probably means I am doing right). I solved this issue by replacing Chrome (The application is running for a very long time) with Safari (I invoke the application just for this purpose) for the upload.
That means, if restart Chrome might also work.
FYI.
In my case I wanted to upload a production certificate to Firebase, and after trying everything I finally realized that I had created a development certificate on iOS Developer...
There might be an inssue of semantics in some cases, so pay attention to meaning.
When you have to upload the certificates in firebase console there are 2 boxes with placeholder text which read:
1. No development APNs certificate
2. No production APNs certificate
In my case, I had understood that I must not upload a development APNs certificate in box 1. Actually, firebase meant that no development Apns certificate has been uploaded yet and that I could upload my certificate.
I was having this problem after my previous p12 had expired, I was trying to upload as a new certificate and was getting the “does not match the current environment” error but it uploaded fine once I updated the expired p12 with the new p12 instead of trying to upload the new one alongside the expired one.

Export push notification certificate as P12

Normally, I can export the certificate from the keychain that I download from the apple member center as a p12 file. However, it seems that Apple may have changed something?!
I require it as a p12 to import it into Amazon's SNS service. I have tried converting to PEM files but it's producing an error on the console.
The solution I have found has been posted here: https://stackoverflow.com/a/19502944/1198404
I copy and paste the answer: Turns out all you have to do is select "My Certificates" on the left panel and it enables the .p12 option.
You can't export to a .p12 because you don't have the private key installed on your machine (if you did, you would have an "expand" arrow next to the certificate like your iPhone Distribution certificate has.) You will need to get the private key from the machine that generated the certificate before you export.
If the accepted answer doesn't apply to you (e.g., because you created the CSR from the same Mac, and should have the private key on this Mac), here's one more possibility:
When you happen to have selected the wrong keychain (like if you accidentally had single clicked on the System keychain rather than Login keychain), you may run into the same problem. If the cert signing request came from that machine, it would associate the private key with the Login keychain (at least, that seems to be the default). So if you somehow then downloaded and imported the certificate into another keychain like the System keychain (or iCloud keychain, as some comments have mentioned), Keychain Access would not find the matching private key and would not put the cert under "My certificates", and so it cannot export a p12. It would be similar to the case of importing to the keychain on a different Mac.
Make sure the import is into the keychain associated with the private key. Often this would be the Login keychain.
You don't have the private key.
So the solution is you have to revoke the previous certificate and create a new APNS profile again.
You can export from Cert just like below.

certificate selected by provision profile is incorrect

I have created certificate & provisioning profile related to my iphone app.
but when I run app it shows doesn't match any valid certificate/private key pair in the default keychain
& then I realize that it is not certificate which i have created.
what should I do now?
I have tried to delete previous certificate but it does also not working it again came back.
You should have the private key used to create the certificate present in your keychain app for you to be able to code sign your app. Start fresh, create a new certificate, this time make sure to store the private key as .p12 file.
You have not installed the .p12 file. Please go through the Apple docs for Certificate/Provisioning-profile creation process. That will help you to understand the whole process of signing an iOS app.
You can always verify certificate, which provision created with.
Provision profile have public key encoded in base64. You can compare hash sums or finger print with private key on your mac.
Here is example code how to export certificate from provision in ruby gist.gitgub

Accidentally deleted the keys in my KeyChain Access and now can't put new ones in

I accidentally deleted the keys in my Keychain Access on my local computer which I use to archive the code when I am ready to submit a new binary.
What I am trying to do to fix this is to go to my IOS PROVISIONING PORTAL, and click on the certificated nav item on the left, and download the dev and production certificates. I do download them, and then drag them to the KeyChain icon, but I am not sure that is doing anything.
And when I try to archive the code, I get this error:
Code Sign error: The identity 'iPhone Distribution: dist_name' doesn't match any valid, non-expired certificate/private key pair in your keychains
Any idea why this is happening and how to fix it?
EDIT:
When I tried to revoke my production certificate, the system said that if I do that, my current live app will no longer work.
There are countless posts regarding this on S.O. already.
When this happens, your best bet is to begin from SCRATCH. Delete all provisioning profiles and re-do the whole procedure.
Else, you'll be stuck for hours trying to solve problems that may or may not be yours.
I had the same issue and had a simple fix
The distribution key and certificate were missing
I was able to download the certificate but couldn't get the key
Asked my team member to export his distribution cert and key.
To do that select the key or cert and export(keychain accesses-> file ->export items-> save on disc).
You will be prompted for the password, remember the password as you need it to extract the files.the files will be saved with extension .p12.
Send the .p12 file to other mac where it needs to be installed
fixed!!

Resources