How to Configure .p12 certificates for APNS on the Azure Platform

https://github.com/has-taiar/PushSharp.Web/wiki/How-to-Configure-.p12-certificates-for-APNS-on-the-Azure-Platform

 

In this document I describe the process in order to use ASPn notification system using PushSharp. This document focused in the import certificate .p12 into Azure platform.

Initial requriments:

  • .p12 file with certificate generated in Mac for using APNs messages.
  • .cer file with certificate of root entity ‘’Apple Worldwide Developer Relations Certification Authority’

Step 1: Prepare the certificates

Azure only accept certificates from .pfx extension files. You have .p12 file that use to send push notification by using pushSharp. Rename this file to .pfx extensions, .pfx and .p12 extensions are the same format. Therefore .p12 file you have ready to import into Azure.

The problem is the second certificate that you need to import into Azure. In this case you have a .cer Certificate file with Root Authority. This .cer you have to convert to .pfx file, for do that you can use this code.

First, create a new windows application in c# in Visual Studio.

In my case I have root certificate ‘Apple Worldwide Developer Relations Certification Authority’ in “c:\trabajo\autoridad.cer “ on my pc.

Change [yourPass] to your password that you want. This password is necessary to import certificate to azure cloud service. Codigo When you run this application you get a new file called “autoridad.pfx” ready to be import into Azure Cloud Service.

Step 1: Create a new Cloud Service

1.- Login to you Azure account 2.- In the left bar you can see “Cloud Services”, then you create a new Cloud Services by clicking New button at the bottom of the page. Codigo 3.- url you can insert the name of cloud services. 4.- When cloud services is created you must edit this cloud services, by clicking over the name column. You can see a new page with a tabbar in top of the page like this: Codigo 5.- Select “Certificates” section. The list is empty now, here you must upload two .pfx files, the root certificate (convert to .pfx by using c# sharp app) as well as .pfx file (that you rename from .p12 file and content the certificate in order to use in pushsharp app). For do this you click “upload” from options in bottom of the page. 6.- Once you import two certificates (only one of them won’t work) the next step is to apply this certificates into your project in visual studio.

Step 3.- Associate certificates with our project in Visual Studio

First at all you must be a solution with your project and Azure deployment. You can see something like this:

Codigo

1.- Open Roles entry in .Azure project 2.- You can see one item, click right click and then Properties.You will see the property page:

Codigo

3.- Select Certificates tab. In this section you must Add two certificated again, but in this case you unable to use file (.pfx), you have to Add certificated manually. 4.- First you can add Authority certificated. Insert some name for this certificate, Select CurrentUser and Root in this case. Last column ask for “Digital fingerprint”, where can I get this data?, in order to get this data do this:

  • In Azure management panel, open “Cloud Service”
  • Select you cloud service (that you create in Step 2), open Certificates tab and then you can see two Digital fingerprint that you use in Visual Studio 5.- Copy & paste into Visual Studio. 6.- You must do the same with second certificate. Only one date you must change. Instead Root you can use “My” for push certificated. Obviously you must be install this certificated in your machine.

4.- How to using .p12 file in this case

In prior steps you has use to files with .pfx extentions, but, in your webServices that using PushSharp code you must be use the sema .p12 file. You add the file to your project and open it from code like this:

Dim appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, “certificates/PushCertificate.p12”))

In my case I add the file to new folder in my project called “certificates”.

5.- Finally, create a Production environment in Cloud Services

1.- When you enter in Cloud Services in Azure management console you can see that the platform says “Any production/testing environment is up” or something like this… you can create a new production or testing environment. 2.- Now, you open Visual Studio again and you have to create a new Package of your project, for do that:

  • Right click over Azure project in your solution
  • Select “Pacage” option from list.
  • This option creates two files, the project package and configuration pagage. You have to see where Visual Studio create them. 3.- Finally, go to Azure platform console and select you Cloud Service. Select “Panel” from options top bar, then select “Upload” from bottom options bar. You have to upload two files (packages) Visual Studio create in prior Step.

Codigo

In this capture you can see “Update” but in your case the title is “Create” I think or something like this.

I hope that this documentation are useful to you.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s