I'm trying to send notification to apps via Google Firebase using .Net SDK. I can send out message successfully on my computer, but fail on my Windows 2016 Server. According to the error message, it seems like a SSL/TLS communication problem.
When I enable all protocol and cipher suites on server, the application runs without a problem. But when I disable TLS 1.0 protocol, it causes a "The client and server cannot communicate, because they do not possess a common algorithm" error when calling SendAsync function. If I enable TLS 1.0 again but disable some weak cipher suites using CBC, it causes a "The request was aborted: Could not create SSL/TLS secure channel." error.
[WebException: The request was aborted: Could not create SSL/TLS secure channel.]
System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) +337
System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar) +145
[HttpRequestException: An error occurred while sending the request.]
Google.Apis.Http.<SendAsync>d__69.MoveNext() +4670
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62
Google.Apis.Auth.OAuth2.Requests.<ExecuteAsync>d__1.MoveNext() +402
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62
Google.Apis.Auth.OAuth2.<RequestAccessTokenAsync>d__38.MoveNext() +492
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32
Google.Apis.Auth.OAuth2.<RefreshTokenAsync>d__12.MoveNext() +766
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32
Google.Apis.Auth.OAuth2.TokenRefreshManager.ResultWithUnwrappedExceptions(Task`1 task) +138
System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke() +104
System.Threading.Tasks.Task.Execute() +71
...
That is really weird. Does the C# SDK only support TLS 1.0 and old cipher suites?? Or it's a .Net framework issue?
Here is my code, in vb.net
Async Function sendMessage(ByVal Message As Messaging.Message) As Threading.Tasks.Task(Of String)
Dim app As FirebaseApp
Try
app = FirebaseApp.Create(New AppOptions With { _
.ProjectId = "xxx", _
.Credential = GoogleCredential.FromFile(Server.MapPath("xxx-yyyy.json")) _
}, "lab6")
Catch ex As Exception
app = FirebaseApp.GetInstance("lab6")
End Try
Dim result As String = ""
Dim firebaseMessagingInstance As FirebaseMessaging = FirebaseMessaging.GetMessaging(app)
result = Await firebaseMessagingInstance.SendAsync(Message)
Return result
End Function
The exception occurs when it calls the SendAsync method.
.Net framework version: 4.6.1
FirebaseAdmin SDK version: 2.2.0
Any idea about why does this happen? Is there any way to force using TLS 1.2 protocol?
Gary