'Strawberry Shake graphql init - use ssl certificate
I am just starting out using Strawberry Shake to generate a client for a GraphQL API.
I have run through the Getting Started, but the API I am connecting to requires SSL Cert authentication.
I can successfully connect to the API using Postman and curl but cannot find anything in the documentation for Strawberry Shake to specify cert / passphrase in the graphql init command
Is this possible?
Solution 1:[1]
Not 100% certain that this is the right way to do it, but the following worked for me
services.AddHttpClient<MyStrawberryShakeClient>(c =>
{
}).ConfigurePrimaryHttpMessageHandler(() =>
{
return new HttpClientHandler
{
ClientCertificateOptions = ClientCertificateOption.Manual,
ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, certChain, policyErrors) => true
};
});
services.AddMyStrawberryShakeClient()
.ConfigureHttpClient(client =>
{
...
});
As far as I'm aware, this isn't secure however, as it just ignores certificate validation entirely
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gary MacGregor-Manzi |
