首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF中的CryptographicException与PushSharp

WCF中的CryptographicException与PushSharp
EN

Stack Overflow用户
提问于 2014-05-09 22:20:36
回答 1查看 885关注 0票数 3

我有一个WCF服务发送推送通知到IOS设备使用APNS。我在使用PushSharp时使用以下代码。

我在"RegisterAppleService“一步中出错了。错误解释是:"CryptographicException未被用户代码处理--参数不正确。“

代码语言:javascript
复制
    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"));

我找不到问题的原因。我该怎么处理这个异常呢?谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-05-12 20:56:53

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

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

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

还要确保在开发阶段使用的是开发/沙箱ssl证书。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23574823

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档