Redth / PushSharp

A server-side library for sending Push Notifications to iOS (iPhone/iPad APNS), Android (C2DM and GCM - Google Cloud Message), Windows Phone, Windows 8, Amazon, Blackberry, and (soon) FirefoxOS devices!
Other
4.38k stars 1.52k forks source link

Passbook Notifications #263

Closed miiisterjim closed 10 years ago

miiisterjim commented 11 years ago

Hi

I've recently implemented our notification service for Passbook and after much tinkering/headaches I believe I've found an issue with Pushsharp for this type of notification.

The issue being that the connection to the APNs (when sending a Passbook Notification only) needs to use the Certificate that has been used to sign the Pass, as this has the pass type identifier embedded within it. Using the standard APNs certificates always successfully sent my notifications, but they were never received by Passbook on the handset. It also always needs to use the production server since there is no concept of a dev/ production pass identifier, there's just a production one.

So, I downloaded the source and altered the following file PushSharp.Apple.ApplePushChannelSettings, altering the CheckProductionCertificateMatching method where the production certificate subject is checked from:

if (production && !subjectName.Contains("Apple Production IOS Push Services")) throw new ArgumentException("You have selected the Production server, yet your Certificate does not appear to be the Production certificate! Please check to ensure you have the correct certificate!");

to:

if (production && !subjectName.Contains("Apple Production IOS Push Services") && !subjectName.Contains("Pass Type ID")) throw new ArgumentException("You have selected the Production server, yet your Certificate does not appear to be the Production certificate! Please check to ensure you have the correct certificate!");

This allows the use of the Passkit certificate and I am now able to connect to the APNs and my device is receiving passboook updates.

Hopefully that all makes sense, and aside from my headache from the last day, Pushsharp is working like a charm, so thanks for that!

Cheers

Redth commented 10 years ago

Thanks, other people in the past have just used the ctor parameter to bypass certificate checking/validation but this is a nice addition to have.

tuler commented 9 years ago

Actually the suggested modification has not been applied yet.