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 static X509CertificateImpl Import (byte[] rawData)
17 var handle = CFHelpers.CreateCertificateFromData (rawData);
18 if (handle != IntPtr.Zero)
19 return new X509CertificateImplApple (handle, true);
21 MX.X509Certificate x509;
23 x509 = new MX.X509Certificate (rawData);
24 } catch (Exception e) {
26 x509 = ImportPkcs12 (rawData, null);
28 string msg = Locale.GetText ("Unable to decode certificate.");
29 // inner exception is the original (not second) exception
30 throw new CryptographicException (msg, e);
34 return new X509CertificateImplMono (x509);