6
我试图通过传递服务器IP,SslProtocols.Tls
和X509Certificate2Collection
使用SslStream.AuthenticateAsClient
方法从C#发送APN。但我收到错误消息: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;
Apple是否颁发了客户端证书? – jww
你有这个工作吗?我试图在这里做完全相同的事情,具有完全相同的错误;) –