gpt4 book ai didi

apns Sharp 中的 iPhone 证书错误 对 SSPI 的调用失败

转载 作者:行者123 更新时间:2023-12-03 18:38:14 24 4
gpt4 key购买 nike

我有一个托管在 azure 中的数据服务,我从该服务向 iphone 发送通知,但在与 apns 建立连接时出现以下错误“对 SSPI 的调用失败。收到的消息是意外的或格式错误。”我还引用了以下链接来解决相同的错误,但仍然收到错误

apple push notification with APNS sharpC# iPhone push server?

        try
{
using (TcpClient client = new TcpClient())
{

try
{
client.Connect("gateway.sandbox.push.apple.com", 2195);
Logging("TSSLProDi :Connected to Apple");
}
catch (Exception ex)
{
Logging("TSSLProDi :" + ex.Message + "-IE-" + ex.InnerException);

}
using (NetworkStream networkStream = client.GetStream())
{
Logging("TSSLProDi :Client connected.");

X509Certificate clientCertificate = new X509Certificate(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"startup\certname.pfx"), "mycertpassword");
X509CertificateCollection clientCertificateCollection = new X509CertificateCollection(new X509Certificate[1] { clientCertificate });

// Create an SSL stream that will close the client's stream.
SslStream sslStream = new SslStream(
client.GetStream(),
false,
new RemoteCertificateValidationCallback(validateServerCertificate),
null
);

try
{
sslStream.AuthenticateAsClient("gateway.sandbox.push.apple.com", clientCertificateCollection, System.Security.Authentication.SslProtocols.Default, false);
Logging("TSSLProDi :slStreamAuthenticated");
}
catch (AuthenticationException ex)
{
Logging("TSSLProDi :" + "Exception: " + ex.Message.ToString());
if (ex.InnerException != null)
{
Logging("Inner exception: " + ex.InnerException.Message.ToString());
}
Logging("TSSLProDi :" + "Authentication failed - closing the connection.");
client.Close();
return;
}
}

}
}
catch (Exception ex)
{

Logging("TSSLProCert :" + ex.Message + "-IE-" + ex.InnerException);
}

我也在虚拟机上安装了所需的证书。我从苹果获得的 iPhone Developer_identity 证书上收到的一个警告是“Windows 没有足够的信息来验证此证书”是我的 iPhone 证书有问题。请帮助我,我被困住了

最佳答案

得到了解决方案,我刚刚将 X509Certificate 更改为 X509Certificate2,将 X509CertificateCollection 更改为 X509Certificate2Collection

关于apns Sharp 中的 iPhone 证书错误 对 SSPI 的调用失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6707364/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com