【问题标题】:APN fails with "Authentication failed because the remote party has closed the transport stream"APN 失败并显示“身份验证失败,因为远程方已关闭传输流”
【发布时间】:2015-09-28 20:39:15
【问题描述】:

我正在尝试通过传递服务器 IP、SslProtocols.Tls 和 X509Certificate2Collection 使用 SslStream.AuthenticateAsClient 方法从 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;

【问题讨论】:

  • 客户端证书是由 Apple 颁发的吗?
  • 你有这个工作吗?我正在尝试在这里做完全相同的事情,但出现完全相同的错误;)

标签: .net openssl apple-push-notifications x509certificate sslstream


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2015-08-20
    • 1970-01-01
    • 2013-03-24
    • 2017-08-18
    • 2022-06-29
    • 1970-01-01
    • 2013-11-07
    • 2017-02-18
    相关资源
    最近更新 更多