You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/grpc/troubleshoot.md
+28-2
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,15 @@ description: Troubleshoot errors when using gRPC on .NET Core.
5
5
monikerRange: '>= aspnetcore-3.0'
6
6
ms.author: jamesnk
7
7
ms.custom: mvc
8
-
ms.date: 08/17/2019
8
+
ms.date: 08/26/2019
9
9
uid: grpc/troubleshoot
10
10
---
11
11
# Troubleshoot gRPC on .NET Core
12
12
13
13
By [James Newton-King](https://twitter.com/jamesnk)
14
14
15
+
This document discusses commonly encountered problems when developing gRPC apps on .NET.
16
+
15
17
## Mismatch between client and service SSL/TLS configuration
16
18
17
19
The gRPC template and samples use [Transport Layer Security (TLS)](https://tools.ietf.org/html/rfc5246) to secure gRPC services by default. gRPC clients need to use a secure connection to call secured gRPC services successfully.
All gRPC client implementations support TLS. gRPC clients from other languages typically require the channel configured with `SslCredentials`. `SslCredentials` specifies the certificate that the client will use, and it must be used instead of insecure credentials. For examples of configuring the different gRPC client implementations to use TLS, see [gRPC Authentication](https://www.grpc.io/docs/guides/auth/).
43
45
46
+
## Call a gRPC service with an untrusted/invalid certificate
47
+
48
+
The .NET gRPC client requires the service to have a trusted certificate. The following error message is returned when calling a gRPC service without a trusted certificate:
49
+
50
+
> Unhandled exception. System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
51
+
> ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
52
+
53
+
You may see this error if you are testing your app locally and the ASP.NET Core HTTPS development certificate is not trusted. For instructions to fix this issue, see [Trust the ASP.NET Core HTTPS development certificate on Windows and macOS](xref:security/enforcing-ssl#trust-the-aspnet-core-https-development-certificate-on-windows-and-macos).
54
+
55
+
If you are calling a gRPC service on another machine and are unable to trust the certificate then the gRPC client can be configured to ignore the invalid certificate. The following code uses [HttpClientHandler.ServerCertificateCustomValidationCallback](/dotnet/api/system.net.http.httpclienthandler.servercertificatecustomvalidationcallback) to allow calls without a trusted certificate:
56
+
57
+
```csharp
58
+
varhttpClientHandler=newHttpClientHandler();
59
+
// Return `true` to allow certificates that are untrusted/invalid
> Untrusted certificates should only be used during app development. Production apps should always use valid certificates.
69
+
44
70
## Call insecure gRPC services with .NET Core client
45
71
46
72
Additional configuration is required to call insecure gRPC services with the .NET Core client. The gRPC client must set the `System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport` switch to `true` and use `http` in the server address:
@@ -50,7 +76,7 @@ Additional configuration is required to call insecure gRPC services with the .NE
Copy file name to clipboardExpand all lines: aspnetcore/tutorials/grpc/grpc-start.md
+4-1
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ author: juntaoluo
4
4
description: This tutorial shows how to create a gRPC Service and gRPC client on ASP.NET Core. Learn how to create a gRPC Service project, edit a proto file, and add a duplex streaming call.
5
5
monikerRange: '>= aspnetcore-3.0'
6
6
ms.author: johluo
7
-
ms.date: 8/23/2019
7
+
ms.date: 8/26/2019
8
8
uid: tutorials/grpc/grpc-start
9
9
---
10
10
# Tutorial: Create a gRPC client and server in ASP.NET Core
Request finished in 78.32260000000001ms 200 application/grpc
307
307
```
308
308
309
+
> [!NOTE]
310
+
> The code in this article requires the ASP.NET Core HTTPS development certificate to secure the gRPC service. If the client fails with the message `The remote certificate is invalid according to the validation procedure.`, the development certificate is not trusted. For instructions to fix this issue, see [Trust the ASP.NET Core HTTPS development certificate on Windows and macOS](xref:security/enforcing-ssl#trust-the-aspnet-core-https-development-certificate-on-windows-and-macos).
0 commit comments