canton7 / RestEase

Easy-to-use typesafe REST API client library for .NET Standard 1.1 and .NET Framework 4.5 and higher, which is simple and customisable. Inspired by Refit
MIT License
1.08k stars 109 forks source link

Request Modifier not reached when chained with ConfigurePrimaryHttpMessageHandler #220

Closed stephenstroud closed 2 years ago

stephenstroud commented 2 years ago

Any ideas? I need the ConfigurePrimaryHttpMessageHandler for self signed cert purposes.


            services.AddRestEaseClient<T>(baseAddress,
                client => { },

                 async (request, cancellationToken) => {                     
                    //do some request changes
                 })
                .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
                 {
                     ClientCertificateOptions = ClientCertificateOption.Manual,
                     ServerCertificateCustomValidationCallback =
                    (httpRequestMessage, cert, cetChain, policyErrors) => {
                        return true;
                    }
                 });
stephenstroud commented 2 years ago

This is kind of related to Issue

Looks like the .ConfigurePrimaryHttpMessageHandler is configured after, but then how do I configure the cert?

stephenstroud commented 2 years ago

In the end I took inspiration in this class and made it work by introducing the ServerCertificateCustomValidationCallback within the constructor.

canton7 commented 2 years ago

Yep it's the same issue. I'll get that fixed in the next release.

canton7 commented 2 years ago

(this issue will get closed automatically when the release goes out)