【问题标题】:pushsharp 2 fires an exception while sending notification to apple iospushsharp 2 在向苹果 ios 发送通知时触发异常
【发布时间】:2016-02-24 12:47:44
【问题描述】:

我使用了 PushSharp 2.0.4,它在向苹果发送通知时触发了一个异常:

您已选择生产服务器,但您的证书似乎不是生产证书!请检查以确保您拥有正确的证书!

我注意到由于苹果证书政策的变化,并且我认为 pushsharp 2 中有一个硬编码值,用于引用旧证书名称。

到目前为止,我不想转移到新的 pushsharp 3 版本,但我想在我的 pushsharp 2.0 代码中解决这个问题。

我认为更改应该在 ApplePushChannelSettings 类中:

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!");
    }
}

在这一行:

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!");
}

但我有一个问题想问任何人之前遇到过这个问题,这是唯一应该做的改变,还有什么是正确的改变,或者具体来说,苹果使用的正确值是什么?

更新: 我评论了 ApplePushChannelSettings.cs 中的一些行、引发异常的行以及仅正确发送到 android 的通知,而问题仍然存在于 ios。

【问题讨论】:

    标签: c# ios pushsharp


    【解决方案1】:

    我找到了一个解决方案,它与windows上的证书配置有关。

    首先,您应该知道苹果对其证书政策和行为进行了细微更改,因此您应该从 PushSharp 2 tp PushSharp 3 转换,您将在我的回答中找到有关升级的所有信息:

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

    此外,如果您有兴趣了解 Apple 所做的更改以及它如何反映到 PushSharp 2,请检查: apple-push-services-created-instead-of-apple-production-ios-push-services

    我还使用 mmc 将证书从用户帐户证书更改为本地计算机证书,并且我在上面的答案中禁用了模拟身份验证和完整详细信息,但我不想再重复了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 2014-06-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多