Redth / PushSharp

A server-side library for sending Push Notifications to iOS (iPhone/iPad APNS), Android (C2DM and GCM - Google Cloud Message), Windows Phone, Windows 8, Amazon, Blackberry, and (soon) FirefoxOS devices!
Other
4.38k stars 1.52k forks source link

PushSharp Apple notifications not working on Windows server 2016 #894

Open gokhurana opened 5 years ago

gokhurana commented 5 years ago

What version of PushSharp are you using?

4.0.10

Describe your issue:

We are using PushSharp to push notifications to Apple Push service. Same code with the same certs was working fine on Windows Server 2012 but stopped working when we upgraded our hosts to Windows server 2016.

What are the steps required to reproduce this issue?

Run PushSharp 4.0.10 on Windows Server 2016 and try to APNs notifications to Apple Service

Please provide any Exception Stack Traces

PushSharp.Apple.ApnsNotificationException: Apns notification error: 'ConnectionError' ---> PushSharp.Apple.ApnsConnectionException: SSL Stream Failed to Authenticate as Client ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The function requested is not supported --- End of inner exception stack trace --- at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception) at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, 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.CheckCompletionBeforeNextReceive(ProtocolToken message, 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.ApnsConnection.d25.MoveNext() --- End of inner exception stack trace --- at PushSharp.Apple.ApnsConnection.d25.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at PushSharp.Apple.ApnsConnection.d21.MoveNext() --- End of inner exception stack trace --- at PushSharp.Apple.ApnsServiceConnection.d2.MoveNext()

sonergonul commented 5 years ago

Did you check the validity of your p12 certificate?

gokhurana commented 5 years ago

Yes, same certificates are working fine on the other hosts (windows server 2012)

gokhurana commented 5 years ago

Also, the error is: System.ComponentModel.Win32Exception: The function requested is not supported

Macaddict42 commented 5 years ago

I'm getting the exact same issue. Just started happening this week.

OkayConnect commented 5 years ago

PushSharp.Apple.ApnsNotificationException: Apns notification error: 'ConnectionError' ---> PushSharp.Apple.ApnsConnectionException: SSL Stream Failed to Authenticate as Client ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The function requested is not supported --- End of inner exception stack trace --- at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception) 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.ApnsConnection.d25.MoveNext() --- End of inner exception stack trace --- at PushSharp.Apple.ApnsConnection.d25.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at PushSharp.Apple.ApnsConnection.d21.MoveNext() --- End of inner exception stack trace --- at PushSharp.Apple.ApnsServiceConnection.d2.MoveNext()

Couple of days back the notifications were working fine. Started getting this error from yesterday. Valid certificates are there. Created new as per some suggestions. But same issue. This issue is happening only in sandbox environment. I tested in production environment and they are working fine.

gokhurana commented 5 years ago

@OkayConnect What operating system version are you running it on? It is happening for me in Sandbox as well and Windows server 2016. We upgraded all our Sandbox to 2016 couple of days ago. It was all good on 2012 earlier. But, reading your comment makes me realize that 2016 may not be the culprit. Also, I am using the same Apple certs in Sandbox and Production.

OkayConnect commented 5 years ago

Mine is Windows server 2012

Macaddict42 commented 5 years ago

I'm running on Windows 10 and I just regenerated all my certificates and still get the same error. I verified my certificate and token are working using Pusher on OS X. It appears to be something wrong with PushSharp.

gokhurana commented 5 years ago

@Macaddict42 - are you running in sandbox or prod? So far what I have observed is that prod has been fine. Not sure why though

gokhurana commented 5 years ago

@Redth - Any idea on this? Same certs work fine when tried with Pusher (https://github.com/noodlewerk/NWPusher). So, it is not a bad cert case and also not a case that Apple is rejecting requests in the Sandbox environment.

gdorigo commented 5 years ago

I have the same problem too, it started on Friday 7 March in the afternoon without any update. The application is on AZURE. The exception that is raised is generic:

Service Exception: PushSharp.Apple.ApplePushService -> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The function requested is not supported --- End of inner exception stack trace --- at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception) 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.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)

gokhurana commented 5 years ago

@gdorigo is this hitting the Sandbox url or Production for Apple Push Service? And, are you using Production certs or Sandbox certs here?

coderxdotwang commented 5 years ago

same issue here from last friday , sounds like something goes wrong with PushSharp for the Sandbox Environment ?

gdorigo commented 5 years ago

@gdorigo is this hitting the Sandbox url or Production for Apple Push Service? And, are you using Production certs or Sandbox certs here?

this is happening only with sandbox certs, production work correctly

Sebastian506563 commented 5 years ago

for me it is happening for prod and sandbox

coderxdotwang commented 5 years ago

this solution works in my case.

james-perfectserve commented 5 years ago

To summarize what @coderxdotwang 's link says

"Temporary fix: System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; Put this in your application_startup or startup.cs"

"It seems that the package in Nuget is not up to date with the code in Github. The latest version in Github supports TLS 1.2, which recently became mandatory. Therefore, the only solution is to clone the repo, build it yourself and add a reference to the newly built DLL."

"I clone PushSharp repo, compile local dll, change project links and it's work, but I don't know why."

@Redth it sounds like the fix is for you to kick off a new nuget publish

danhudsonfortyau commented 5 years ago

OOOh, please push a new nuget to include the TLS update.

danhudsonfortyau commented 5 years ago

The last two links are references to the updated PushSharp nuget. I'm not sure if the original author is trying to monentize PushSharp or if its a branch of someone else's. I ran the nuget packages and got past the current set of Tls errors related to Apple updates. Hope this helps folks.

https://nugetmusthaves.com/Package/LogicSoftware.PushSharp https://nugetmusthaves.com/Package/LogicSoftware.PushSharp https://nugetmusthaves.com/Package/PushSharp.NetCore2.1