2014-11-04 54 views
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?

回答

1

由於存在嚴重的安全漏洞,SSL3在上個月(2014年10月)已被Apple(其中包括)傾銷;稱爲POODLE(填充Oracle降級傳統加密)。

+0

好的,那麼使用Tls的錯誤呢? – 2014-11-05 05:15:24

相關問題