7ba425257f592e7432baac6850c980b0a5d22f94
[mono.git] / mcs / class / System / Mono.Net.Security / MonoTlsProviderFactory.Droid.cs
1 // Copyright 2015 Xamarin Inc. All rights reserved.
2 #if SECURITY_DEP
3 using System;
4 using MSI = Mono.Security.Interface;
5 #if HAVE_BTLS
6 using Mono.Btls;
7 #endif
8
9 namespace Mono.Net.Security
10 {
11         static partial class MonoTlsProviderFactory
12         {
13                 static MSI.MonoTlsProvider CreateDefaultProviderImpl ()
14                 {
15                         MSI.MonoTlsProvider provider = null;
16                         var type = Environment.GetEnvironmentVariable ("XA_TLS_PROVIDER");
17                         switch (type) {
18                         case null:
19                         case "default":
20                         case "legacy":
21                                 return new LegacyTlsProvider ();
22                         case "btls":
23 #if HAVE_BTLS
24                                 if (!MonoBtlsProvider.IsSupported ())
25                                         throw new NotSupportedException ("BTLS in not supported!");
26                                 return new MonoBtlsProvider ();
27 #else
28                                 throw new NotSupportedException ("BTLS in not supported!");
29 #endif
30                         default:
31                                 throw new NotSupportedException (string.Format ("Invalid TLS Provider: `{0}'.", provider));
32                         }
33                 }
34         }
35 }
36 #endif