证书的iOS推送通知AuthenticationException [英] iOS Push Notifications AuthenticationException for Certificate
问题描述
我正在尝试使用PushSharp向我的应用发送推送通知.我有两个Apple帐户...一个是普通帐户,另一个是企业帐户.我的普通帐户上有一个开发人员证书可以使用,但是我的开发证书和发行证书都无法从企业帐户中使用.我收到身份验证异常.
I am trying to use PushSharp to send a push notification to my app. I have two Apple accounts... one is a regular account, and the other is an Enterprise account. I have a developer certificate on the regular account that works, but both my development and distribution certificates fail to work from the Enterprise account. I get an Authentication Exception..
A call to SSPI failed, see inner exception.
Inner Exception:
[System.ComponentModel.Win32Exception]: {"An unknown error occurred while processing the certificate"}
在PushSharp的这段代码中会发生这种情况(我没有注释掉该行):
This occurs in this code of PushSharp (I didn't comment the line out):
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);
}
这是我的测试项目中的代码:
Here is the code from my test project:
public static void SendPingToApple()
{
try
{
var devicetoken = "mytoken";
var appleCert = File.ReadAllBytes(AssemblyPathName + @"\Resources\DistPrivKey1.p12");
var push = new PushBroker();
push.RegisterAppleService(new ApplePushChannelSettings(IsProduction, appleCert, "password"));
push.QueueNotification(new AppleNotification()
.ForDeviceToken(devicetoken.ToUpper())
.WithAlert("Test Notification"));
push.StopAllServices();
}
catch (Exception ex)
{
throw;
}
}
推荐答案
使用以下命令将ssl证书转换为pem格式
Convert your ssl certificates to pem format using following commands
openssl pkcs12 -in yourP12File.pfx -nocerts -out privateKey.pem
openssl pkcs12 -in yourP12File.pfx -clcerts -nokeys -out publicCert.pem
然后运行以下命令,以确保证书或网络连接没有问题.
Then run following command to ensure that there is no issue with your certificate or network connection.
openssl s_client-连接gateway.sandbox.push.apple.com:2195 -cert YourSSLCertAndPrivateKey.pem -debug -showcerts -CAfile"Entrust.net 证书颁发机构(2048).pem"
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert YourSSLCertAndPrivateKey.pem -debug -showcerts -CAfile "Entrust.net Certification Authority (2048).pem"
您应该下载Entrust证书并将其转换为pem,因为APNS证书是由Entrust签名的.
You should download Entrust certificate and convert it to pem as APNS certificates are signed by Entrust.
这篇关于证书的iOS推送通知AuthenticationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!