We are using a slightly modified version of PushSharp v2.2.1.0 that recently stopped working in our latest build. We are unable to update it to the 4.x or 3.x versions due to time constraints on the rewrite. After several days of tinkering with most aspects of the code, I am unsure of what else can be causing the issue.
We receive the following error whenever we try to process data (so far it looks like only on the Apple side of things):
A call to SSPI failed, see inner exception.
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.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.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.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.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)
Inner Exception: System.ComponentModel.Win32Exception (0x80004005)
The message received was unexpected or badly formatted
We already had the fix mentioned here in place. Short of posting a lot of code I am unsure what information will help with debugging. We receive no issues or errors retrieving and loading the certificate (logging indicates it is correctly loaded and the right versions). We did do a recent update to this cert as the old one expired, but the new one is being loaded correctly.
Nothing has changed about our infrastructure that would imply a change in inbound data. There were some masking changes to secure account information, but removing those changes did not resolve the issue, and it should only occur during logging anyway. What am I missing?
Since I found several answers that came close to this problem but didn't quite solve it (and because PushSharp's Git page has indicated they have no interest in issues from 2.x) I'll put my specific answer in hopes it helps someone:
My issue revolves around the new cert. While we did install a new cert, we did not add the p12 file that held the cert's private key, so messages could not be properly encrypted.
Installing the p12 file to the server resolved the issue.
All in all, a fairly obvious solution to a problem that was being overthought.