首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >对SSPI的调用失败错误

对SSPI的调用失败错误
EN

Stack Overflow用户
提问于 2013-09-01 17:27:11
回答 1查看 8.4K关注 0票数 3

我使用PushSharp在C#中发送苹果推送通知,我有我的生产.pem文件及其密码。下面是我的代码snippet.Am总是会收到这个错误。

代码语言:javascript
复制
"A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The message received was unexpected or badly formatted-" 

代码语言:javascript
复制
"System.IO.IOException: Authentication failed because the remote party has closed the transport stream."

我尝试了net.Even中几乎所有可用的代码都尝试了MoonAPNS,但是相同的错误,因为自定义脚本也得到了这个SSPI失败错误。我使用相同的.pem文件并运行一个php脚本从同一服务器向APN发送推送通知,它可以工作。

代码语言:javascript
复制
var push = new PushBroker();
var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ck.pem"));
 push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, "pwd")); 
 push.QueueNotification(new AppleNotification()
                                           .ForDeviceToken("XXXXXXXXXXXXXXX")
                                           .WithAlert("Hello World!")
                                           .WithBadge(7)
                                           .WithSound("sound.caf"));


                LogManager.Info("Waiting for Queue to Finish..");
                push.StopAllServices();

请提前帮忙谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-03 06:24:22

我认为您的c#可能是不正确的,以验证,而不是使用.pem,您是否可以尝试使用您的p12证书使用以下代码作为测试.

代码语言:javascript
复制
    Boolean bsandbox = true;
    string p12fileName =AppDomain.CurrentDomain.BaseDirectory + "yourCert.p12";
    string p12password = "1234";

    string deviceID1 = "2909b25e0c699b2dc4864b4b9f719e67aac7e0fab791a72a086ffb788ba28f6a"; //
    string msg = "This is the message sent at : ";
    string alert = "Hello world at " + DateTime.Now.ToLongTimeString();
    int badge = 1;
    string soundstring = "default";
    var payload1 = new NotificationPayload(deviceID1, alert, badge, soundstring);
    payload1.AddCustom("custom1", msg); 

    var notificationList = new List<NotificationPayload> { payload1 };



    var push = new PushNotification(bsandbox, p12fileName, p12password);

    var rejected = push.SendToApple(notificationList);`
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18560980

复制
相关文章

相似问题

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