我想用PushSharp發送推送通知給我的應用程序。我有兩個蘋果賬戶......一個是普通賬戶,另一個是企業賬戶。我在常規帳戶上有開發人員證書,但我的開發證書和分發證書都無法通過企業帳戶工作。我得到一個驗證異常..iOS推送通知AuthenticationException證書
A call to SSPI failed, see inner exception.
Inner Exception:
[System.ComponentModel.Win32Exception]: {"An unknown error occurred while processing the certificate"}
這發生在PushSharp的代碼(我沒有發表評論線路輸出):
try
{
stream.AuthenticateAsClient(this.appleSettings.Host, this.certificates, System.Security.Authentication.SslProtocols.Ssl3, false);
//stream.AuthenticateAsClient(this.appleSettings.Host);
}
catch (System.Security.Authentication.AuthenticationException ex)
{
throw new ConnectionFailureException("SSL Stream Failed to Authenticate as Client", ex);
}
這裏是我的測試項目中的代碼:
public static void SendPingToApple()
{
try
{
var devicetoken = "mytoken";
var appleCert = File.ReadAllBytes(AssemblyPathName + @"\Resources\DistPrivKey1.p12");
var push = new PushBroker();
push.RegisterAppleService(new ApplePushChannelSettings(IsProduction, appleCert, "password"));
push.QueueNotification(new AppleNotification()
.ForDeviceToken(devicetoken.ToUpper())
.WithAlert("Test Notification"));
push.StopAllServices();
}
catch (Exception ex)
{
throw;
}
}
您是否嘗試使用openssl和使用企業證書連接到apns服務?首先確認您的證書沒有問題。 – Nilesh
不是嗎?我不清楚該怎麼做。你能詳細說明嗎? –
你應該運行這個命令:openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert YourSSLCertAndPrivateKey.pem -debug -showcerts -CAfile「Entrust.net Certification Authority(2048).pem」根據你正在使用哪種證書。如果無法連接,則證書或網絡配置有問題。 – Nilesh