【问题标题】:PushSharp Exception : The credentials supplied to the package were not recognizedPushSharp 异常:无法识别提供给包的凭据
【发布时间】:2015-09-09 17:37:58
【问题描述】:

我在使用 Pushsharp 的 IOS 推送通知中出现以下异常。我搜索了很多文章,但不清楚如何继续。Andoid 工作正常只是这个 IOS 的问题。

例外:

System.ComponentModel.Win32Exception (0x80004005): The credentials supplied to the package were not recognized
   at System.Net.SSPIWrapper.AcquireCredentialsHandle(SSPIInterface SecModule, String package, CredentialUse intent, SecureCredential scc)
   at System.Net.Security.SecureChannel.AcquireCredentialsHandle(CredentialUse credUsage, SecureCredential& secureCredential)
   at System.Net.Security.SecureChannel.AcquireClientCredentials(Byte[]& thumbPrint)
   at System.Net.Security.SecureChannel.GenerateToken(Byte[] input, Int32 offset, Int32 count, Byte[]& output)
   at System.Net.Security.SecureChannel.NextMessage(Byte[] incoming, Int32 offset, Int32 count)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
   at PushSharp.Apple.FeedbackService.Run(ApplePushChannelSettings settings, CancellationToken cancelToken)
   at PushSharp.Apple.ApplePushService.<ApplePushService>c__AnonStorey0.<>m__1(Object state)}

我的代码:

    PushBroker 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(@"C:\Data\abc\Cert\CCDevelopment.p12"); 
    push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, "password")); //Extension method
   push.QueueNotification(new AppleNotification()                                                                      .ForDeviceToken("tokenId") //dev
                                 .WithAlert(msg) //load
                                 .WithBadge(1));  //

【问题讨论】:

    标签: c# ios push-notification pushsharp


    【解决方案1】:

    我已经找到了问题所在。我再次撤销并重新生成了证书,这一次,我只在 Keychain 访问中导出了私钥(没有证书),导出为 .p12 并使用了新文件,并且它有效。出于某种原因,当文件中同时存在证书和私钥时,PushSharp 不能很好地处理 .p12。

    推荐链接 PushSharp APNS production: The credentials supplied to the package were not recognized (development works fine though)

    【讨论】:

      【解决方案2】:

      在使用 Windows 证书存储时(恕我直言,这是在生产服务器上管理证书的最简单方法),请务必在私钥上设置正确的权限。

      【讨论】:

        【解决方案3】:

        经过 4 小时的测试:

        .p12 转换为.pem,它将适用于 IIS 受限用户....

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2014-06-13
          • 1970-01-01
          • 2021-05-31
          • 1970-01-01
          • 2014-07-27
          • 2011-01-20
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多