我有一个托管在 azure 中的数据服务,我从中向 iphone 发送通知,但是在与 apns 建立连接时,我收到以下错误“对 SSPI 的调用失败。收到的消息是意外的或格式错误。” 我还参考了以下链接以获取相同的错误,但仍然收到错误
带有 APNS 锐利和 C# iPhone 推送服务器的苹果推送通知?
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);
}
我也在 VM 上安装了所需的证书。 我从苹果获得的 iphone developer_identity 证书上收到的一个警告是“Windows 没有足够的信息来验证此证书”是不是我的 iphone 证书有问题。请帮帮我,我卡住了