【问题标题】:SslStream.AuthenticateAsClient Exception when using iPhone Apple Push Notification Provider (apns-sharp)使用 iPhone Apple Push Notification Provider (apns-sharp) 时出现 SslStream.AuthenticateAsClient 异常
【发布时间】:2010-01-19 15:47:38
【问题描述】:

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

推送通知在我的开发机器上工作,但在 Rackspace 云托管中不起作用。我有与我的开发人员一起运行的确切 Rackspace Cloud 自定义中等信任配置。机器,所以中等信任在这里不是问题。此外,证书文件也不是问题,因为它适用于我的开发人员。机器。

有什么想法吗?

更新 #1:这是否与 Entrust 根服务器有关,可能位于 Rackspace 云服务器上?我检查了 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()

【问题讨论】:

  • 您是否曾尝试在 web.config 中使用模拟以希望 X509KeyStorageFlags.MachineKeySet 正常工作?我遇到了和你一样的情况,我现在正在尝试与 Rackspace 合作解决它。我还尝试将 .p12 的路径以及原始字节传递给新的 X509Certificate2 但也没有运气。
  • 不,我相信 Rackspace 由于中等信任设置而无法解决问题。我将设计更改为使用 PHP 访问 APNS。

标签: c# iphone apple-push-notifications sslstream


【解决方案1】:

【讨论】:

  • 我会试一试并报告。两个开发人员都不会出现这个问题。如果这是原因,机器和生产云?
  • 我刚刚完成了这个测试(只选择证书而不是同时选择两者),它并没有解决生产服务器上的问题。
【解决方案2】:

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

我有同样的例外,阅读“apns-sharp”中的所有程序和论坛并没有帮助。从 MAC 导出证书一切都很好,我的问题是,当我使用默认配置在本地机器上安装证书时,由于未导入 privateKey,因此无法使用该证书. 然后当你打开一个新证书安装它时,你应该确保安装私钥。 在代码中你应该有类似的东西:

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

这解决了我的问题。

【讨论】:

  • 为我工作。与 Apple 推送证书相关的其他可用答案对我不起作用。
【解决方案3】:

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

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

【讨论】:

    【解决方案4】:

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

    【讨论】:

      猜你喜欢
      • 2011-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      • 2012-06-09
      相关资源
      最近更新 更多