2 using System.Runtime.InteropServices;
3 using MX = Mono.Security.X509;
4 using XamMac.CoreFoundation;
6 namespace System.Security.Cryptography.X509Certificates
8 static partial class X509Helper
10 public static X509CertificateImpl InitFromHandle (IntPtr handle)
12 return new X509CertificateImplApple (handle, false);
15 public static X509CertificateImpl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
17 MX.X509Certificate x509;
19 if (password == null) {
20 handle = CFHelpers.CreateCertificateFromData (rawData);
21 if (handle != IntPtr.Zero)
22 return new X509CertificateImplApple (handle, true);
25 x509 = new MX.X509Certificate (rawData);
26 } catch (Exception e) {
28 x509 = X509Helper.ImportPkcs12 (rawData, null);
30 string msg = Locale.GetText ("Unable to decode certificate.");
31 // inner exception is the original (not second) exception
32 throw new CryptographicException (msg, e);
38 x509 = X509Helper.ImportPkcs12 (rawData, password);
41 // it's possible to supply a (unrequired/unusued) password
43 x509 = new MX.X509Certificate (rawData);
47 return new X509CertificateImplMono (x509);