2015-06-23 129 views
2

我使用Pushsharp.I獲得IOS推送通知的以下異常。我搜索了很多文章,但沒有弄清楚如何繼續.. Andoid工作正常與這個IOS。PushSharp異常:提供給包的憑據未被識別

例外:

System.ComponentModel.Win32Exception (0x80004005): The credentials supplied to the package were not recognized 
    at System.Net.SSPIWrapper.AcquireCredentialsHandle(SSPIInterface SecModule, String package, CredentialUse intent, SecureCredential scc) 
    at System.Net.Security.SecureChannel.AcquireCredentialsHandle(CredentialUse credUsage, SecureCredential& secureCredential) 
    at System.Net.Security.SecureChannel.AcquireClientCredentials(Byte[]& thumbPrint) 
    at System.Net.Security.SecureChannel.GenerateToken(Byte[] input, Int32 offset, Int32 count, Byte[]& output) 
    at System.Net.Security.SecureChannel.NextMessage(Byte[] incoming, Int32 offset, Int32 count) 
    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.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) 
    at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) 
    at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) 
    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.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) 
    at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) 
    at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) 
    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.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) 
    at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) 
    at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) 
    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.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) 
    at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) 
    at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, 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 System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation) 
    at PushSharp.Apple.FeedbackService.Run(ApplePushChannelSettings settings, CancellationToken cancelToken) 
    at PushSharp.Apple.ApplePushService.<ApplePushService>c__AnonStorey0.<>m__1(Object state)} 

我的代碼:

PushBroker push = new PushBroker(); 
    push.OnNotificationSent += NotificationSent; 
    push.OnChannelException += ChannelException; 
    push.OnServiceException += ServiceException; 
    push.OnNotificationFailed += NotificationFailed; 
    push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired; 
    push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged; 
    push.OnChannelCreated += ChannelCreated; 
    push.OnChannelDestroyed += ChannelDestroyed; 
    var appleCert = File.ReadAllBytes(@"C:\Data\abc\Cert\CCDevelopment.p12"); 
    push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, "password")); //Extension method 
    push.QueueNotification(new AppleNotification()                  .ForDeviceToken("tokenId") //dev 
           .WithAlert(msg) //load 
           .WithBadge(1)); // 

回答

0

當使用Windows證書存儲區,(恕我直言,以管理在生產服務器上的證書最簡單的方法),一定要設置的私鑰正確的權限。

0

4小時測試後:

轉換.p12.pem,它會與IIS有限的用戶工作....