private void InitFromHandle (IntPtr handle)
{
if (handle != IntPtr.Zero) {
// both Marshal.PtrToStructure and Marshal.Copy use LinkDemand (so they will always success from here)
CertificateContext cc = (CertificateContext) Marshal.PtrToStructure (handle, typeof (CertificateContext));
byte[] data = new byte [cc.cbCertEncoded];
Marshal.Copy (cc.pbCertEncoded, data, 0, (int)cc.cbCertEncoded);
x509 = new Mono.Security.X509.X509Certificate (data);
}
// for 1.x IntPtr.Zero results in an "empty" certificate instance
}
#endif