gpt4 book ai didi

.net - APN 失败并显示 "Authentication failed because the remote party has closed the transport stream"

转载 作者:行者123 更新时间:2023-12-01 18:11:32 33 4
gpt4 key购买 nike

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

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;

最佳答案

禁用 SSL3 后我遇到了同样的情况。生成新证书后,它就可以工作了。

关于.net - APN 失败并显示 "Authentication failed because the remote party has closed the transport stream",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31334970/

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