pushsharp 2 fires an exception while sending notification to apple ios
Asked Answered
O

1

0

I used PushSharp 2.0.4 and its fires an exception while sending notification to apple:

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!

I notice that due to change in apple certificate policies and i think there are a hard coded value in the pushsharp 2 that referee to the old certificate name.

I don't want to transfer to the new pushsharp 3 version till now but i want to fix this issue in my pushsharp 2.0 code.

I think the change should be in ApplePushChannelSettings class:

private void CheckProductionCertificateMatching(bool production)
{
    if (this.Certificate == null)
    {
        throw new ArgumentNullException("You must provide a Certificate to connect to APNS with!");
    }
    string name = this.Certificate.IssuerName.Name;
    string name2 = this.Certificate.SubjectName.Name;
    if (!name.Contains("Apple"))
    {
        throw new ArgumentException("Your Certificate does not appear to be issued by Apple!  Please check to ensure you have the correct certificate!");
    }
    if (production && !name2.Contains("Apple Production IOS Push Services") && !name2.Contains("Apple 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!");
    }
    if (!production && !name2.Contains("Apple Development IOS Push Services") && !name2.Contains("Pass Type ID"))
    {
        throw new ArgumentException("You have selected the Development/Sandbox (Not production) server, yet your Certificate does not appear to be the Development/Sandbox certificate!  Please check to ensure you have the correct certificate!");
    }
}

In this line:

if (production && !name2.Contains("Apple Production IOS Push Services") && !name2.Contains("Apple 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!");
}

But I have a question for any one faced this issue before, is this the only change should done and also what is the correct change to be done or to be specific what is the correct value that apple used instead of this?

Update: I commenting some lines in ApplePushChannelSettings.cs, the lines that fire exception, and the notifications sent correctly to android only and the issue still in ios.

Odle answered 24/2, 2016 at 12:47 Comment(0)
O
0

I found a solution and it was related to certificate configuration on windows.

First of all you should to know that apple making a minor changes to it's certificates policies and behavior so you should convert from PushSharp 2 tp PushSharp 3 and you will found all about the upgrade here in my answer:

production-certificate-error-in-push-notification-pushsharp

Also if you are interested to know about the changes that apple make and how it reflect to PushSharp 2 check that: apple-push-services-created-instead-of-apple-production-ios-push-services

also i used mmc to change certificate from user account certificate to local computer certificate and i disabled the impersonation authentication and the full details in my above answer but i don't want to repeat again.

Odle answered 26/2, 2016 at 12:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.