2011-01-07 4 views
2

私はasp.net、C#を使用してiphoneに通知をプッシュしようとしています。このコード行で、「リモート側がトランスポートストリームを閉じたために認証に失敗しました」というエラーが表示されます。APNS SSlStreamリモートパーティがトランスポートストリームを閉じたために認証に失敗しました

sslStream.AuthenticateAsClient( "gateway.sandbox.push.apple.com"、clientCertificateCollection、SslProtocols.Ssl3、false);

誰でも私にこれを助けることができます。

ありがとうございます。

sslStream.AuthenticateAsClient( "gateway.sandbox.push.apple.com"、clientCertificateCollection、SslProtocols.Default、偽);:

答えて

0

は個人的に私はこれを使用します

  using (TcpClient client = new TcpClient()) 
      { 


       client.Connect("gateway.sandbox.push.apple.com", 2195); 


       using (NetworkStream networkStream = client.GetStream()) 
       { 
        try 
        { 

         SslStream sslStream = new SslStream(client.GetStream(), false); 


         try 
         { 
          sslStream.AuthenticateAsClient("gateway.sandbox.push.apple.com", "gateway.sandbox.push.apple.com", SslProtocols.Default, false); 
          //building messages 
          sslStream.Write(msg); 
          sslStream.close(); 
+1

ありがとうマリノス。あなたのコード行をチェックしましたが、同じエラーを返します。あなたはC#を使用してこのAPNSのためのコードとステップを投稿してください。前もって感謝します。あなたの助けは非常に高く評価されています。 – Kodee

2

あなたはX509Certificate2CollectionにX509Certificate2とX509CertificateCollectionにのX509Certificateを変更して試すことができます。

2

最近、私もエラーを受け取りました: "受信したメッセージは予期しないか、フォーマットが正しくありませんでした。内部例外と

を手伝ってくれたもの「相手は、トランスポートストリームを閉じたため、認証に失敗したが、」少しOpenSslStream方法 を変更することです - TSLはSSLプロトコルで

古いコード:

apnsStream.AuthenticateAsClient(
    this.Host, this.certificates, 
    System.Security.Authentication.SslProtocols.Ssl3, 
    false 
); 

新しいコード:

apnsStream.AuthenticateAsClient(
    this.Host, this.certificates, 
    System.Security.Authentication.SslProtocols.Ssl3 | System.Security.Authentication.SslProtocols.Tls, 
    false 
); 

うまくいけば、それは誰か...

+0

同じ問題がありました。私のケースでは、両方のソリューションX509Certificate - > X509Certificate2、X509CertificateCollectionをX509Certificate2Collectionに適用した後にSslProtocols.Tlsフラグを追加することで問題が解決されました。したがって、両方の回答が正しいので、どちらもトピックを解決する必要があります – Madman

0

を助ける私は、問題はここにあなたがそれをするのopensslで次のコマンドを使用することができ、サーバーの開発効率向上に証明書にappleから証明書を変換持っていると思う:

  • Command1を: opensslのX509 -in "apn_developer_identity.pem" -outform PEM
  • command2の-out -inform DER "apn_developer_identity.cer": "pushkey1.pem" -passin -out のopensslのpkcs12 -in -nocerts "pushkey1.p12"パス:yourpass - パスアウトパス:yourpass
  • COMMAND3: "apn_developer_identity.p12" -out "apn_developer_identity.pem" -in のopensslのpkcs12 -export -inkey "pushkey1.pemは" 合格-passin:yourpassは合格-passout:yourpass
0

は、以下のコード をお試しくださいsslStream.AuthenticateAsClient( "gateway.sandbox.push.apple.com"、clientCertificateCollection、SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls、false);

0

秘密鍵でのみ証明書を作成してください。

関連する問題