12

PushSharp のバージョン 2.1.2 を使用しています。アプリは .NET 4.5.1 です (ただし、.NET 4.5 と .NET 4 もターゲットにしてみました)

サンドボックス Apple APNS を介してプッシュ メッセージを送信しようとしていますが、成功しません。

ここで提供されている Ray Wenderlich のウォークスルーで提供されている PHP スクリプトを使用して、同じ証明書を使用し、PushSharp アプリと同じデバイス ID に送信して、 メッセージを正常に送信しています。

完成した証明書をキー チェーンから p12 としてエクスポートしてテストしました。完成した証明書とキーをエクスポートしています。秘密鍵のエクスポート。こちらもこちらの方法で。PHP スクリプトで使用する証明書とキーを組み合わせると、問題はありません。

テストしたマシンにp12証明書をインポートしました-違いはないようです。

Apple プッシュ サービスをプッシュ ブローカーに登録するときに、IsProduction フラグを変更してみました。本番環境として設定してもエラーはありませんが (これはサンドボックス証明書ですが)、その場合も明らかにデバイスに到達しません。

私のメッセージはどれも通過せず、すべて次のようなサービス例外が発生します。

System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The message received was unexpected or badly formatted
 --- End of inner exception stack trace ---
at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at PushSharp.Apple.FeedbackService.Run(ApplePushChannelSettings settings, CancellationToken cancelToken)
at PushSharp.Apple.ApplePushService.<>c__DisplayClass4.<.ctor>b__1(Object state)

これは基本的に私のコードがどのように見えるかです:

var push = new PushBroker();
// register event handlers for channel create/destroy/exception, notificationrequeue, serviceexception, notification sent

var appleCert = File.ReadAllBytes(ConfigurationManager.AppSettings["CertAddress"]);
push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, ConfigurationManager.AppSettings["CertPassword"]));

var pn = new AppleNotification().ForDeviceToken(item.SendToDeviceIdentifier).WithAlert(item.AlertMessage).WithBadge(item.Badges);

push.QueueNotification(pn);

チャネルアップイベントが呼び出され、次にサービス例外が発生します。

関連する質問のいくつかは、このエラーがファイアウォールの問題に関連している可能性があると述べています.プッシュ通知を送信できる2つの異なるネットワークでアプリをテストしました(そのうちの1つは現在PushSharpアプリを使用しています).

どんな洞察も大歓迎です。

4

2 に答える 2

30

非推奨の APNS-Sharp ライブラリ (PushSharp の祖先) を使用して同じ問題が発生していました。テストに基づいて問題を修正する APNS-Sharp のプル リクエストを送信しました。

変更は (ApplePushChannel.cs で) 変更することでした

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

stream.AuthenticateAsClient(this.appleSettings.Host, this.certificates, System.Security.Authentication.SslProtocols.Tls, false);

これに関する確認は見つかりませんでしたが、Sandbox APNS で SSL3 プロトコルがサポートされなくなったようです。この問題を報告した他の人たちと同様に、本番 APNS に対する私の通知はまだ機能していました。

プル リクエストは次の場所にあります。

https://github.com/Redth/PushSharp/pull/369/files

アップデート

Apple Developer Web サイトには、このトピックに関するスレッドがあります。

https://devforums.apple.com/thread/224320?tstart=0

ただし、このスレッドまたは github スレッドにいる人もいます。したがって、情報は確かに偏っています。Apple の担当者は次のように言っています。

正式なドキュメントはまだ出ていませんが、APNS は SSL ではなく TLS に移行しているようです (この変更を確認したことだけに基づいており、公式には何も聞いていません)。

于 2014-04-16T22:24:34.710 に答える