Strawberry Shake graphql init - use ssl certificate

761 views Asked by At

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?

1

There are 1 answers

10
Brickscrap On

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