2
我試着送蘋果推送通知與有效P12和令牌如下關閉讀取數據:APNS C#例外無法從傳輸連接現有的連接被強行遠程主機
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.Authentication.SslProtocols.Ssl3我得到「身份驗證失敗,因爲遠程方已關閉傳輸流」
如何發送APNS? 我如何發送apns?
好的,那麼使用Tls的錯誤呢? – 2014-11-05 05:15:24