Introducing a general-purpose dependency injector to use `System` code from within `corlib`.
Dependency Injector
===================
* `corlib/Mono/DependencyInjector.cs`: this is corlib's entry point.
* `corlib/Mono/ISystemDependencyProvider.cs`: this interface is implemented in `System.dll`.
* `System/Mono/SystemDependencyProvider.cs`: the `System.dll` side of it.
To use this, we need to call `SystemDependencyProvider.Initialize()` during system startup on Mobile
(this is already done for Android, but still needs to be done for XI/XM).
For Desktop, this will be triggered by a few `System.dll` based APIs such as for instance `SslStream`
or `X509Certificate2` - and the corlib side can use reflection if needed.
The corlib side should use `DependencyInjector.GetSystemDependency()`.
X509Certificate - corlib side
=============================
We previously had a mechanic called `INativeCertificateHelper` (which unfortunately was not really
working as intended) to use the BTLS code (which lives in System) in corlib. This has now been
replaced to use the new dependency injector.
The actual implementation as well as all the platform conditionals have now been moved into `System.dll`
where they can take advantage of existing PAL code.
This also removes all `Mono.Security.X509` usage from the `System.Security.Cryptography.X509Certificates`
namespace (it is still used by some of the other crypto classes, so we can't remove it yet).
* `Mono/ISystemCertificateProvider.cs`: this interface is now hooked up via the new
dependency injector and replaces `INativeCertificateHelper`.
* `System.Security.Cryptography.X509Certificates/X509Helper.cs`: this file has been completely
reworked and is now just a tiny stub around `ISystemCertificateProvider` and will eventually go
away completely. The entire implementation has been moved into `System.dll`.
* `System.Security.Cryptography.X509Certificates/X509CertificateImplMono.cs`: removed, we now use
`X509Certificate2ImplMono` from System via `ISystemCertificateProvider`.
* `System.Security.Cryptography.X509Certificates/X509CertificateImplApple.cs`: moved into `System.dll`
and slightly reworked there.
* `System.Security.Cryptography.X509Certificates/X509Helper.Apple.cs`: removed, we do not have any
platform-specific code here anymore; the new `ISystemCertificateProvider` provides this for us.
X509Certificate - System side
=============================
The actual implementation as well as all the platform-specific code now lives in `System.dll`.
* `Mono/SystemCertificateProvider.cs`: the `System.dll` implementation of `ISystemCertificateProvider`.
We do the platform / TLS Provider checks in here, then construct a custom PAL class.
* `Mono/X509Pal.cs`: New internal static class.
* `Mono/X509PalImpl.cs`: New abstract internal class. It contains some common code, including the
fallback implementation.
* `Mono/X509PalImpl.Mono.cs`: Fallback PAL, used by platforms without SslStream / MonoTlsProvider.
* `Mono.Btls/X509PalImpl.Btls.cs`: BTLS implementation.
* `Mono.AppleTls/X509PalImpl.Apple.cs`: We are using the `MONO_FEATURE_APPLE_X509` conditional in
here, so it can be used without the actual Apple TLS code.
* `Mono.AppleTls/X509CertificateImplApple.cs`: moved here from corlib.
* `Mono.AppleTls/*.cs`: Use the `X509CertificateImplApple(IntPtr)` constructor everywhere instead of
`X509Certificate(IntPtr)` to make sure we are using the "correct" PAL.
28 files changed: