diff options
author | Martin Baulig <martin.baulig@xamarin.com> | 2015-10-30 22:15:26 +0300 |
---|---|---|
committer | Martin Baulig <martin.baulig@xamarin.com> | 2015-10-30 23:42:44 +0300 |
commit | d1b4e3adb9b558d02782bbb5880358dd8f632e4d (patch) | |
tree | 5c9ee01c85ff9cc13ba149d61f5bfbf329244b6c /mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs | |
parent | 18b9eb403f592e4d6f0c67f19758cb1a1d77ce15 (diff) |
[Mono.Security]: Add 'MonoTlsSettings.TrustAnchors' and 'CertificateValidationHelper.SupportsTrustAnchors'.
This is currently only supported on iOS and Mac (check 'CertificateValidationHelper.SupportsTrustAnchors')
and will pass a set of trusted root certificates to the OS validation function. Use for self-signed
certificates instead of providing a custom callback.
Diffstat (limited to 'mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs')
-rw-r--r-- | mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs b/mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs index 95c37210282..e2c9a05c158 100644 --- a/mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs +++ b/mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs @@ -99,13 +99,24 @@ namespace Mono.Security.Interface { const string SecurityLibrary = "/System/Library/Frameworks/Security.framework/Security"; static readonly bool noX509Chain; + static readonly bool supportsTrustAnchors; static CertificateValidationHelper () { #if MONOTOUCH || XAMMAC noX509Chain = true; + supportsTrustAnchors = true; + #elif MONODROID + noX509Chain = true; + supportsTrustAnchors = false; #else - noX509Chain = File.Exists (SecurityLibrary); + if (File.Exists (SecurityLibrary)) { + noX509Chain = true; + supportsTrustAnchors = true; + } else { + noX509Chain = false; + supportsTrustAnchors = false; + } #endif } @@ -113,6 +124,10 @@ namespace Mono.Security.Interface get { return !noX509Chain; } } + public static bool SupportsTrustAnchors { + get { return supportsTrustAnchors; } + } + internal static ICertificateValidator GetDefaultValidator (MonoTlsSettings settings) { return (ICertificateValidator)NoReflectionHelper.GetDefaultCertificateValidator (settings); |