xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.47k stars 514 forks source link

Expand TrustOverride with NSUrlSession or NSUrl #7413

Closed EGoverde closed 4 years ago

EGoverde commented 4 years ago

This is a feature request to expand the functionality of TrustOverride on iOS to allow for better SSL pinning based on the requested URL.

Steps to Reproduce

  1. Create a new NSUrlSessionHandler
  2. Implement the TrustOverride with a NSUrlSessionHandlerTrustOverrideCallback

Expected Behavior

In the callback, it should be possible to check the URL that triggered it. This allows to check if the URL should match a given certificate or not. If it should, the certificate could be compared to another certificate and the request can then be allowed or disallowed.

Actual Behavior

Currently only information regarding the certificate is supplied to the callback, but no data about the NSUrlSession is supplied.

Suggestion

Environment

=== Visual Studio Enterprise 2019 for Mac ===

Version 8.3.8 (build 8)
Installation UUID: 1a7d29f5-d352-4a23-b7b7-6bd7ec96b352
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 5.16.1.24 (d16-3 / 08809f5b)

    Package version: 604000208

=== Mono Framework MDK ===

Runtime:
    Mono 6.4.0.208 (2019-06/07c23f2ca43) (64-bit)
    Package version: 604000208

=== Xamarin.iOS ===

Version: 13.6.0.12 (Visual Studio Enterprise)
Hash: e3c2b406d
Branch: xcode11.2
Build date: 2019-11-01 00:12:08-0400
mandel-macaque commented 4 years ago

Very valid request. I need to check if this is needed after the changes that are coming from the new implementation of the HttpClient from corfx. If that is the case, I'll implement the required change, else I'll write here why is not needed.