Beispiel #1
0
 public void RemoveFromKeyChain(X509Certificate certificate)
 {
     using (var secCert = new SecCertificate(certificate))
         using (var identity = SecKeyChain.FindIdentity(secCert, true)) {
             SecKeyChain.RemoveIdentity(identity);
         }
 }
Beispiel #2
0
 public bool IsInKeyChain(X509Certificate certificate)
 {
     using (var secCert = new SecCertificate(certificate)) {
         var identity = SecKeyChain.FindIdentity(secCert, false);
         if (identity != null)
         {
             identity.Dispose();
         }
         return(identity != null);
     }
 }
        public static SecIdentity GetIdentity(X509Certificate certificate)
        {
            /*
             * If we got an 'X509Certificate2', then we require it to have a private key
             * and import it.
             */
            var certificate2 = certificate as X509Certificate2;

            if (certificate2 != null)
            {
                return(SecIdentity.Import(certificate2));
            }

            /*
             * Otherwise, we require the private key to be in the keychain.
             */
            using (var secCert = new SecCertificate(certificate)) {
                return(SecKeyChain.FindIdentity(secCert, true));
            }
        }