Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get bundle id from p12/pem file

Is it possible to get application's bundle id from p12/pem file for APNS?

I have a system where user can upload his push certificate (p12 or pem) and would be great to show him an info about bundle id so user will be able to check what he uploaded

like image 971
Rubycon Avatar asked Mar 20 '15 16:03

Rubycon


People also ask

How do I check my p12 certificate?

You can view the contents of a p12 key by installing OpenSSL, an open-source cryptography toolkit, and entering the command openssl pkcs12 -info -nodes -in yourfilename. p12 at your PC's command line.

What is PEM file vs p12?

Pem is a container format. It can include just the public certificate, or public key, private key, and root certificates. p12 is commonly used to bundle a private key with a certificate.

How do I make a PEM file Apple Push Notification?

Go to https://developer.apple.com and login to your Apple Developer Account. Select Certificates, Identifiers, Profiles. Select tab Production, then Click (+) Add to add a new Certificate. On Select Type page, select Apple Push Notification service SSL (Sanbox & Production).


1 Answers

I'm not sure whether it's 100% helpful but you can use command line tool from openssl library in the following manner

openssl pkcs12 -info -in mycert.p12 -passin pass:MyCertPassPhrase

this will produce the output you can parse

MAC Iteration 1
MAC verified OK
PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 2048
Certificate bag
Bag Attributes
    friendlyName: Apple Production IOS Push Services: com.mybundle.domain
    localKeyID: F2 FZ 5D 00 44 73 F1 64 B8 FF EF 37 82 BC 13 F4 81 6A B2 14 
subject=/UID=com.mybundle.domain/CN=Apple Production IOS Push Services: com.mybundle.domain/OU=Q7QX7A5JZ7/C=RU
issuer=/C=US/O=Apple Inc./OU=Apple Worldwide Developer Relations/CN=Apple Worldwide Developer Relations Certification Authority
-----BEGIN CERTIFICATE-----
MIIFeTCCBGGgAwIBAgIILW8Tn/Z054IwDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV

where com.mybundle.domain is what you're looking for.

like image 72
heximal Avatar answered Oct 11 '22 13:10

heximal