5 // Martin Baulig <martin.baulig@xamarin.com>
7 // Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 using Mono.Security.Interface;
28 using System.Security.Cryptography.X509Certificates;
30 namespace Mono.Btls.Interface
32 public static class BtlsProvider
34 public static bool IsSupported ()
36 return MonoBtlsProvider.IsSupported ();
39 public static MonoTlsProvider GetProvider ()
41 return new MonoBtlsProvider ();
44 public static BtlsX509 CreateNative (byte[] data, BtlsX509Format format)
46 var x509 = MonoBtlsX509.LoadFromData (data, (MonoBtlsX509Format)format);
47 return new BtlsX509 (x509);
50 public static X509Certificate CreateCertificate (byte[] data, BtlsX509Format format, bool disallowFallback = false)
52 return MonoBtlsProvider.CreateCertificate (data, (MonoBtlsX509Format)format, disallowFallback);
55 public static X509Certificate2 CreateCertificate2 (byte[] data, BtlsX509Format format, bool disallowFallback = false)
57 return MonoBtlsProvider.CreateCertificate2 (data, (MonoBtlsX509Format)format, disallowFallback);
60 public static X509Certificate2 CreateCertificate2 (byte[] data, string password, bool disallowFallback = false)
62 return MonoBtlsProvider.CreateCertificate2 (data, password, disallowFallback);
65 public static BtlsX509Chain CreateNativeChain ()
67 return new BtlsX509Chain (new MonoBtlsX509Chain ());
70 public static BtlsX509Store CreateNativeStore ()
72 return new BtlsX509Store (new MonoBtlsX509Store ());
75 public static BtlsX509StoreCtx CreateNativeStoreCtx ()
77 return new BtlsX509StoreCtx (new MonoBtlsX509StoreCtx ());
80 public static X509Chain CreateChain ()
82 return MonoBtlsProvider.CreateChain ();
85 public static string GetSystemStoreLocation ()
87 return MonoBtlsProvider.GetSystemStoreLocation ();
90 public static BtlsX509VerifyParam GetVerifyParam_SslClient ()
92 return new BtlsX509VerifyParam (MonoBtlsX509VerifyParam.GetSslClient ());
95 public static BtlsX509VerifyParam GetVerifyParam_SslServer ()
97 return new BtlsX509VerifyParam (MonoBtlsX509VerifyParam.GetSslServer ());
100 public static X509Chain GetManagedChain (BtlsX509Chain chain)
102 return MonoBtlsProvider.GetManagedChain (chain.Instance);