private void Init(string password) { IntPtr cert; IntPtr pkey; IntPtr cacerts; // Parse the PKCS12 object and get privatekey, cert, cacerts if available Native.ExpectSuccess(Native.PKCS12_parse(ptr, password, out pkey, out cert, out cacerts)); if (cert != IntPtr.Zero) { certificate = new X509Certificate(cert, true); if (pkey != IntPtr.Zero) { privateKey = new CryptoKey(pkey, true); // We have a private key, assign it to the cert certificate.PrivateKey = privateKey.CopyRef(); } } if (cacerts != IntPtr.Zero) { caCertificates = new Stack <X509Certificate>(cacerts, true); } else { caCertificates = new Stack <X509Certificate>(); } }