Apns c#异常无法从传输连接读取数据远程主机强制关闭了现有连接
本文关键字:连接 主机 程主机 异常 传输 数据 读取 Apns | 更新日期: 2023-09-27 18:29:10
我正在尝试发送带有有效p12和令牌的苹果推送通知,如下所示:
void connect()
{
client = new TcpClient();
//Notify we are connecting
var eoc = this.OnConnecting;
if (eoc != null)
eoc(this.appleSettings.Host, this.appleSettings.Port);
try
{
client.Connect(this.appleSettings.Host, this.appleSettings.Port);
}
catch (Exception ex)
{
throw new ConnectionFailureException("Connection to Host Failed", ex);
}
if (appleSettings.SkipSsl)
{
networkStream = client.GetStream();
}
else
{
stream = new SslStream(client.GetStream(), false,
new RemoteCertificateValidationCallback((sender, cert, chain, sslPolicyErrors) => { return true; }),
new LocalCertificateSelectionCallback((sender, targetHost, localCerts, remoteCert, acceptableIssuers) =>
{
return certificate;
}));
try
{
stream.AuthenticateAsClient(this.appleSettings.Host, this.certificates, System.Security.Authentication.SslProtocols.Tls, false);
//stream.AuthenticateAsClient(this.appleSettings.Host);
}
catch (System.Security.Authentication.AuthenticationException ex)
{
throw new ConnectionFailureException("SSL Stream Failed to Authenticate as Client", ex);
}
if (!stream.IsMutuallyAuthenticated)
throw new ConnectionFailureException("SSL Stream Failed to Authenticate", null);
if (!stream.CanWrite)
throw new ConnectionFailureException("SSL Stream is not Writable", null);
networkStream = stream;
}
//Start reading from the stream asynchronously
Reader();
}
}
当我将行代码:System.Security.Authentication.SslProtocols.Tls更改为System.Security.Aauthentication.SllProtocols.Ssl3时,我得到"由于远程方关闭了传输流,身份验证失败"
如何发送APNS?我怎样才能发送弹片???
SSL3在上个月(2014年10月)内因重大安全漏洞被苹果(以及其他公司)丢弃;称为POODLE(在降级的传统加密上填充Oracle)。