.net APN失败,出现“故障”;身份验证失败,因为远程方已关闭传输流;

.net APN失败,出现“故障”;身份验证失败,因为远程方已关闭传输流;,.net,openssl,apple-push-notifications,x509certificate,sslstream,.net,Openssl,Apple Push Notifications,X509certificate,Sslstream,我正试图通过传递服务器IP、SslProtocols.Tls和X509Certificate2Collection来使用SslStream.authenticatesClient方法从C#发送APN。但我收到一条错误消息: Authentication failed because remote party has closed the transport stream 我已经尝试了这里讨论的每一个解决方案,但没有任何效果。请帮助下面是代码 X509Certificate2Collection

我正试图通过传递服务器IP、
SslProtocols.Tls
X509Certificate2Collection来使用
SslStream.authenticatesClient
方法从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后,我遇到了同样的情况。生成新证书后,它开始工作。

客户端证书是由苹果公司颁发的吗?你有这个功能吗?我试图在这里做完全相同的事情,错误完全相同;)