使用 iPhone Apple 推送通知提供程序 (apns-sharp) 时出现 SslStream.AuthenticateAsClient 异常

发布于 2024-08-18 08:50:09 字数 3424 浏览 3 评论 0原文

使用 Apple 推送通知提供程序 (apns-sharp) 时,我收到以下异常。

推送通知可以在我的开发计算机上运行,​​但无法在 Rackspace 云托管中运行。我的开发人员正在运行精确的 Rackspace Cloud 自定义介质信任配置。机器,因此中等信任不是这里的问题。另外,证书文件不可能是问题,因为它适用于我的开发人员。机器。

有什么想法吗?

更新#1:这是否与 Rackspace 云服务器上可能不存在的 Entrust 根服务器有关?我检查了 apns-sharp 代码,看起来它忽略了证书验证,但我不能 100% 确定。

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.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 JdSoft.Apple.Apns.Notifications.NotificationConnection.OpenSslStream()
  at JdSoft.Apple.Apns.Notifications.NotificationConnection.Reconnect()
  at JdSoft.Apple.Apns.Notifications.NotificationConnection.workerMethod()

I receive the following exception when using the Apple Push Notification Provider (apns-sharp).

The push notifications work on my development machine however it will not work within the Rackspace Cloud hosting. I have the exact Rackspace Cloud custom medium trust configuration running with my dev. machine so the medium trust can't be the issue here. Also, the certificate file can't be the issue as it works on my dev. machine.

Any ideas?

Update #1: Would this have something to do with the Entrust root server that may not be on the Rackspace Cloud servers? I checked into the apns-sharp code and it looks like it ignores the certificate verification but I'm not 100% sure.

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.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 JdSoft.Apple.Apns.Notifications.NotificationConnection.OpenSslStream()
  at JdSoft.Apple.Apns.Notifications.NotificationConnection.Reconnect()
  at JdSoft.Apple.Apns.Notifications.NotificationConnection.workerMethod()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

反目相谮 2024-08-25 08:50:09

对于继续遇到此异常的人:

我也遇到了同样的异常,并且阅读“apns-sharp”中的所有过程和论坛并没有帮助。从 MAC 导出证书一切都很好,我的问题是,当我使用默认配置在本地计算机中安装证书时,无法使用该证书,因为未导入 privateKey
然后当您打开新证书安装它时,您应该确保安装私钥。
在代码中你应该有这样的内容:

new X509Certificate2(rawCertificateInBytes, Password, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet);

这已经解决了我的问题。

For people that continues getting this exception:

I had the same exception and reading about all procedures and forums in 'apns-sharp' did not help. All was good about export the certificate from the MAC, my problem was that as I was installing the certificate in the local machine with the configurations by default, that certificate could not be used because the privateKey was not imported.
Then when you open a new certificate to install it, you should ensure to install the private key.
In code you should have something like:

new X509Certificate2(rawCertificateInBytes, Password, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet);

That has solved my problem.

油焖大侠 2024-08-25 08:50:09

您是否关注过此页面:
http://code.google.com/p/apns-sharp/wiki/ HowToCreatePKCS12Certificate

另外,您可能有兴趣查看最新版本的 apns-sharp。它解决了许多问题。

Did you follow this page:
http://code.google.com/p/apns-sharp/wiki/HowToCreatePKCS12Certificate

Also, you may be interested in checking out the latest version of apns-sharp. It has many issues resolved.

挽袖吟 2024-08-25 08:50:09

在我的情况下,此问题与我无法解决的 Rackspace 云站点上的中等信任安全性有关。为了克服这个问题,我改变了设计,使用 PHP 代码来访问 APNS。

In my situation this issue was related to the Medium Trust security on the Rackspace Cloud Sites that I was unable to resolve. To overcome this issue I changed the design to use PHP code to access the APNS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文