我的应用程序刚刚在 App Store 上准备上架,但是我所有已经从 App Store 安装了该应用程序的生产设备都无法接收推送通知。当我尝试向生产设备发送推送通知时,我得到了以下错误:
"The credentials supplied to the package were not recognized"
(System.ComponentModel.Win32Exception)
这个异常在一个无限循环中被内部抛出并捕获:
它在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);
}
这是在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)
这是我尝试过的:
- 双重检查我正在尝试使用的设备ID是否已注册生产设备令牌。
- 吊销并重新生成APNS生产证书,将其与私钥一起导出到新的
.p12
文件中,并尝试使用新证书再次发送推送通知。(我在处理开发推送通知时遇到了相同的问题,这解决了我的问题)。 - 将SSL协议从
Ssl3
更改为Tls
。(几天前有一个协议版本问题,而它暂时解决了一个问题。不应该需要这样做,但我收到的错误与之前遇到的错误相同,而这种方法可以解决)。 - 检查我是实际上正在尝试使用生产证书连接到生产服务器,而不是开发服务器/证书。
- 检查我能否直接访问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
为什么PushSharp无法与APNS服务器协商?