首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS推送通知证书的AuthenticationException

iOS推送通知证书的AuthenticationException
EN

Stack Overflow用户
提问于 2014-02-21 23:18:10
回答 1查看 5.2K关注 0票数 1

我正在尝试使用PushSharp向我的应用程序发送推送通知。我有两个苹果账户..。一个是常规帐户,另一个是企业帐户。我的常规帐户上有一个开发人员证书,但我的开发和分发证书都无法从企业帐户中运行。我得到了身份验证异常..。

代码语言:javascript
复制
A call to SSPI failed, see inner exception.

Inner Exception:
[System.ComponentModel.Win32Exception]: {"An unknown error occurred while processing the certificate"}

这发生在PushSharp的代码中(我没有注释这一行):

代码语言:javascript
复制
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);
}

下面是我的测试项目的代码:

代码语言:javascript
复制
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;
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-22 01:09:36

使用以下命令将ssl证书转换为pem格式

代码语言:javascript
复制
    openssl pkcs12 -in yourP12File.pfx -nocerts -out privateKey.pem

    openssl pkcs12 -in yourP12File.pfx -clcerts -nokeys -out publicCert.pem

然后运行以下命令,以确保您的证书或网络连接没有问题。

openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert YourSSLCertAndPrivateKey.pem -debug -showcerts -CAfile "Entrust.net证书颁发机构(2048年).pem“

您应该下载Entrust证书并将其转换为pem,因为APNS证书是由Entrust签名的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21947135

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档