【问题标题】:CryptographicException in WCF with PushSharp带有 PushSharp 的 WCF 中的 CryptographicException
【发布时间】:2014-06-27 19:06:45
【问题描述】:

我有一个 WCF 服务,可以使用 APNS 向 IOS 设备发送推送通知。我将以下代码与 PushSharp 一起使用。

我在“RegisterAppleService”步骤中遇到错误。错误解释是: "CryptographicException 未被用户代码处理 参数不正确。”

    private static PushBroker push;

    public string SendNotification()
    {
        push = new PushBroker();
        push.OnNotificationSent += NotificationSent;
        push.OnChannelException += ChannelException;
        push.OnServiceException += ServiceException;
        push.OnNotificationFailed += NotificationFailed;
        push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
        push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
        push.OnChannelCreated += ChannelCreated;
        push.OnChannelDestroyed += ChannelDestroyed;

        var appleCert = File.ReadAllBytes("CERT_FILE_NAME.p12");
        push.RegisterAppleService(new ApplePushChannelSettings(appleCert, "PASSWORD"));

        string devToken = "DEVICE_TOKEN";
        push.QueueNotification(new AppleNotification()
                                   .ForDeviceToken(devToken)
                                   .WithAlert("Hello World!")
                                   .WithBadge(7)
                                   .WithSound("sound.caf"));

我找不到问题的原因。我该如何处理该异常? 谢谢。

【问题讨论】:

    标签: wcf push-notification apple-push-notifications pushsharp cryptographicexception


    【解决方案1】:

    我怀疑您只使用了签名请求生成的密钥,而不是证书本身。

    https://github.com/Redth/PushSharp/wiki/How-to-Configure-&-Send-Apple-Push-Notifications-using-PushSharp

    此处提供了这些步骤,在第 18 步中,请确保您要导出与密钥相关联的证书,而不仅仅是密钥本身。

    还要确保您在开发阶段使用开发/沙盒 ssl 证书。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-20
      • 1970-01-01
      • 2011-07-23
      • 2017-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多