APN失败,显示“由于远程方关闭了传输流而导致身份验证失败”。

6

我正在尝试使用 SslStream.AuthenticateAsClient 方法从C#发送APN,通过传递服务器IP、SslProtocols.TlsX509Certificate2Collection。但是我收到了一个错误消息:

Authentication failed because remote party has closed the transport stream

我尝试了这里讨论的每个解决方案,但都无效。请帮忙看一下以下代码:

X509Certificate2Collection certs = new X509Certificate2Collection();

X509Certificate2 xcert = new X509Certificate2();
xcert.Import(@"D:\certify.p12", "password", X509KeyStorageFlags.UserKeySet);


certs.Add(xcert);

// Apple development server address
string apsHost;

if (xcert.ToString().Contains(ProductionKeyFriendName))
  apsHost = "gateway.push.apple.com";
else
  apsHost = "gateway.sandbox.push.apple.com"; 

// Create a TCP socket connection to the Apple server on port 2195

TcpClient tcpClient = new TcpClient();
tcpClient.Connect(apsHost, 2195);

// Create a new SSL stream over the connection
sslStream = new SslStream(tcpClient.GetStream());

// Authenticate using the Apple cert

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
sslStream.AuthenticateAsClient(apsHost, certs, System.Security.Authentication.SslProtocols.Tls, false);

return true;

客户端证书是由苹果颁发的吗? - jww
1
你成功了吗?我在这里尝试做完全相同的事情,遇到了完全相同的错误 ;) - Nick Prozee
1个回答

1

在禁用SSL3后,我遇到了相同的情况。 生成新证书后问题得到解决。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接