PushSharp APNS 生产:无法识别提供给包的凭据(尽管开发工作正常) [英] PushSharp APNS production: The credentials supplied to the package were not recognized (development works fine though)

查看:20
本文介绍了PushSharp APNS 生产:无法识别提供给包的凭据(尽管开发工作正常)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My app just got ready for sale on App Store, but none of my production devices (devices that have installed the app from App Store) are getting push notifications. When I try to send a push notification to a production device, I am getting this error:

"The credentials supplied to the package were not recognized" 
(System.ComponentModel.Win32Exception)

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

This exception is internally thrown and caught in an infinite loop:

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

It is thrown at line 539 of ApplePushChannel.cs file:

    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 输出中的输出:

This is the output of the application in Visual Studio Output:

...
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)

以下是我尝试过的方法:

Here are the things I've tried:

  • 仔细检查我正在尝试的设备 ID 是否已使用生产设备令牌注册.
  • 撤销并重新生成 APNS 生产证书,将其与私钥一起导出到新的 .p12 文件,然后使用新证书再次尝试.(我在开发推送通知方面遇到了同样的问题,这解决了我的问题)
  • 将 SSL 协议从 Ssl3 更改为 Tls.(几天前协议版本有问题,暂时解决了一个问题.应该不需要这个,但我得到的错误与我之前得到的错误相同,但已修复)
  • 检查我实际上是在尝试使用生产证书而不是开发服务器/证书连接到生产服务器.
  • 检查我是否可以直接访问 APNS 服务器(我的 ASP.NET 应用程序位于我的 Mac 上的 Parallels VM Windows 8.1 中,这是我的 Mac 的输出,只是为了避免混淆:
  • Double checked that the device ID I'm trying is registered with a production device token.
  • Revoked and regenerated the APNS Production certificate, exported it with the private key to a new .p12 file, and tried again with the new certificate. (I had the same problem with development push notifications, and this solved my problem)
  • Changed the SSL protocol from Ssl3 to Tls. (a few days ago there was a problem with protocol version, and it fixed a problem temporarily. There shouldn't be need for this, but the error I'm getting is the same as the one I was getting before which this fixed)
  • Checked that I'm actually trying to connect to production server with the production certificate instead of development server/certificate.
  • Checked that I can access the APNS server directly (my ASP.NET app lives inside a Parallels VM Windows 8.1 at my Mac, here is the output from my Mac, just to avoid confusion:

(终端输出)我正在 ping 沙盒服务器,我已经 ping 生产服务器,我确认我也可以连接到它,所以这不是问题.

(Terminal output) I was pinging the sandbox server, I've pinged the production server, I verify that I can connect to it too, so it's not the issue.

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 服务器协商?

Why would PushSharp not negotiate with APNS servers?

推荐答案

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

I figured out the problem. I revoked and regenerated the certificate again, and this time I only exported the private key (without the certificate). In Keychain access, I exported as .p12 and used the new file and it worked. For some reason, PushSharp wasn't play well with .p12 when both certificate and private key are present in the file.

这篇关于PushSharp APNS 生产:无法识别提供给包的凭据(尽管开发工作正常)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆