Open rbergerjr opened 9 months ago
@JunielKatarn Can you look at this? Does this seem like the right approach to adding this functionality? (See linked PR).
@jonthysell I have followed up with @rbergerjr and suggested a simplified approach (using a filter factory function instead of a filter "editor").
More details on the PR's thread.
Currently awaiting the next commits to approve.
Summary
In order for XHRRequests from javascript layer to request to certificate protected endpoints, a client certificate must be added to the underlying WinRT HttpClient.
Certificate configuration is performed through the HttpBaseProtocolFilter object via the HttpBaseProtocolFilter::ClientCertificate property. The
HttpBaseProtocolFilter
, or more generally anIHttpFilter
, is passed intoHttpClient
at construction.Applications need to configure the http stack's
HttpBaseProtocolFilter
beforeHttpClient
construction. New API is a novel property set on theReactInstanceSettings::Properties()
property bag. The property value is a delegate of typevoid(winrt::Windows::Web::Http::Filters::IHttpBaseProtocolFilter& filter)
. If the property is set, the delegate is called duringHttpClient
configuration inIHttpResource::Make
to allow application code to modifyHttpBaseProtocolFilter
. ModifiedHttpBaseProtocolFilter
is then passed toHttpClient
duringHttpModule
init.Alternatives designs considered were:
HttpClient
. Discarded as not minimum viable, and additional complexities with overriding currentOriginPolicy
configuration ofHttpClient
.Motivation
Enterprise applications often have to access protected endpoints which can be guarded by a certificate. In order for javascript layer to access certificate protected endpoints, the React Native Windows http stack needs to be configured to include the certificate.
React Native Windows uses WinRT's HttpClient to facilitate network requests from javascript layer. HttpClient needs to be configured with certificate in order to facilitate javascript requests to certificate protected endpoints.
Basic Example
In
ReactNativeHost
setup, add property toReactInstanceSettings::Properties
via setter inNetworking/HttpBaseProtocolFilterModifierSettings.h
Open Questions
No response