PushSharp APNS生产:提供给包的凭据无法识别(开发工作正常)

Can*_*ğlu 29 ssl production-environment apple-push-notifications pushsharp

我的应用程序刚刚在App Store上销售,但我的生产设备(从App Store安装了应用程序的设备)都没有获得推送通知.当我尝试向生产设备发送推送通知时,我收到此错误:

"The credentials supplied to the package were not recognized" 
(System.ComponentModel.Win32Exception)
Run Code Online (Sandbox Code Playgroud)

内部抛出此异常并陷入无限循环:

在此输入图像描述

它被抛出ApplePushChannel.cs文件的第539行:

    try
{
    stream.AuthenticateAsClient(this.appleSettings.Host, this.certificates, 
        System.Security.Authentication.SslProtocols.Ssl3, false);
    //stream.AuthenticateAsClient(this.appleSettings.Host);
}
catch (System.Security.Authentication.AuthenticationException ex)
{
    throw new ConnectionFailureException("SSL Stream Failed to Authenticate as Client", ex);
}
Run Code Online (Sandbox Code Playgroud)

这是Visual Studio输出中应用程序的输出:

...
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
...(it keeps getting thrown until I stop it manually)
Run Code Online (Sandbox Code Playgroud)

以下是我尝试过的事情:

  • 仔细检查我正在尝试的设备ID是否已注册生产设备令牌.
  • 撤销并重新生成APNS Production证书,使用私钥将其导出到新.p12文件,然后再次使用新证书.(我在开发推送通知方面遇到了同样的问题,这解决了我的问题)
  • 已将SSL协议更改Ssl3Tls.(前几天协议版本出现了问题,它暂时修复了一个问题.应该不需要这个,但是我得到的错误与我之前得到的错误相同)
  • 检查我实际上是尝试使用生产证书而不是开发服务器/证书连接到生产服务器.
  • 检查我是否可以直接访问APNS服务器(我的ASP.NET应用程序位于我的Mac上的Parallels VM Windows 8.1中,这是Mac的输出,只是为了避免混淆:

(终端输出) 编辑:我正在ping沙盒服务器,我已经ping了生产服务器,我验证我也可以连接它,所以这不是问题.

can$ sudo nmap -p 2195 gateway.sandbox.push.apple.com
Starting Nmap 6.40-2 ( http://nmap.org ) at 2014-04-28 00:06 EEST
Nmap scan report for gateway.sandbox.push.apple.com (17.149.34.189)
Host is up (0.49s latency).
Other addresses for gateway.sandbox.push.apple.com (not scanned): 17.149.34.187 17.149.34.188
PORT     STATE SERVICE
2195/tcp open  unknown
Run Code Online (Sandbox Code Playgroud)

为什么PushSharp不与APNS服务器协商?

Can*_*ğlu 80

我解决了这个问题.我再次撤销并重新生成了证书,这次我只导出了私钥(没有证书).在Keychain访问中,我导出.p12并使用了新文件并且它有效.出于某种原因,.p12当文件中存在证书和私钥时,PushSharp不能很好地运行.

  • 这个.这个.这个.所有文档都告诉您导出两个项目然后失败.浪费了几个小时和几个小时.谢谢@CanPoyrazoğlu. (7认同)
  • 谢谢,我只是重新做了证书,它工作了!虽然我认为这不是PushSharp的一个问题,但我认为在制作这些证书这一非常复杂的过程中出现问题.所以开始新鲜似乎纠正了这一点. (3认同)
  • 出于某种原因,导出这两个项目的工作原理是从mac中的php,但在c#server中失败.通过仅使用私钥来实现它. (3认同)