googleapis / googleapis/google-cloud-dotnet

Question: Is it possible to bypass certificate validation in the WebRiskServiceClient?

Open
#15,505 1 comment 0 reactions 0 assignees View on GitHub
priority: p3 type: feature request
Dominant language
C#
Stars
1.1k
Forks
411
Avg merge
7h 29m
Merged PRs (30d)
57

Description

I am using WebRiskServiceClient in package Google.Cloud.WebRisk.V1 in a dotnet application, and I trying to disable SSL validation due to having issues with certificates when using a Wiremock container.

This is my current code sample (I am using the RestGrpcAdapter because WireMock is much less hassle to use with http requests).

```
services.AddHttpClient()
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true,
});

services.AddWebRiskServiceClient((provider, builder) =>
{
builder.GrpcAdapter = RestGrpcAdapter.Default;
builder.Endpoint = "https://localhost:8443"; // Wiremock

var options = provider.GetRequiredService>().Value;
builder.ApiKey = options.ApiKey;
});
```

However, I am not convinced it is picking up the HttpClient I have configured. When the WebServiceClient performs a call (SearchUris in this case) I get an exception raised "_The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch, RemoteCertificateChainErrors._"

What is the correct way to overrride the HttpClient here?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.