コード例 #1
0
 public void MailX1()
 {
     using (var cert = new X509Certificate(mail_google_com)) {
         /*
          * This X509Certificate constructor will use SecCertificateCreateWithData() and
          * store the SecCertificateRef in its Handle.
          */
         Assert.That(cert.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle");
         Assert.That(CFGetRetainCount(cert.Handle), Is.EqualTo(1), "RetainCount");
         using (var sc = new SecCertificate(cert)) {
             Assert.That(sc.Handle, Is.EqualTo(cert.Handle), "Same Handle");
             CheckMailGoogleCom(sc, 2);
             Assert.That(cert.ToString(true), Is.EqualTo(sc.ToX509Certificate().ToString(true)), "X509Certificate");
         }
     }
 }
コード例 #2
0
        public void MailX1()
        {
            using (var cert = new X509Certificate(mail_google_com)) {
                /*
                 * This X509Certificate constructor will use SecCertificateCreateWithData() and
                 * store the SecCertificateRef in its Handle.
                 */
                Assert.That(cert.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle");
                Assert.That(CFGetRetainCount(cert.Handle), Is.EqualTo((nint)1), "RetainCount");
                using (var sc = new SecCertificate(cert)) {
#if NET
                    // dotnet PAL layer does not return the same instance
                    CheckMailGoogleCom(sc, 1);                      // so the new one is RC == 1
#else
                    Assert.That(sc.Handle, Is.EqualTo(cert.Handle), "Same Handle");
                    CheckMailGoogleCom(sc, 2);                      // same handle means another reference was added
#endif
                    Assert.That(cert.ToString(true), Is.EqualTo(sc.ToX509Certificate().ToString(true)), "X509Certificate");
                }
            }
        }
コード例 #3
0
 public X509Certificate GetAppleCertificate(X509Certificate certificate)
 {
     // This will remove the private key if we have any.
     using (var appleCert = new SecCertificate(certificate))
         return(appleCert.ToX509Certificate());
 }