public SecTrust (X509Certificate2 certificate, SecPolicy policy) { if (certificate == null) throw new ArgumentNullException ("certificate"); using (SecCertificate cert = new SecCertificate (certificate)) { Initialize (cert.Handle, policy); } }
public SecTrust(X509CertificateCollection certificates, SecPolicy policy) { if (certificates == null) throw new ArgumentNullException ("certificates"); SecCertificate[] array = new SecCertificate [certificates.Count]; int i = 0; foreach (var certificate in certificates) array [i++] = new SecCertificate (certificate); Initialize (array, policy); }
public SecStatusCode SetAnchorCertificates(X509Certificate2Collection certificates) { if (handle == IntPtr.Zero) { throw new ObjectDisposedException("SecTrust"); } if (certificates == null) { return(SecTrustSetAnchorCertificates(handle, IntPtr.Zero)); } SecCertificate[] array = new SecCertificate [certificates.Count]; int i = 0; foreach (var certificate in certificates) { array [i++] = new SecCertificate(certificate); } return(SetAnchorCertificates(array)); }
SecStatusCode SetAnchorCertificates (SecCertificate[] array) { using (var certs = CFArray.FromNativeObjects (array)) { return SecTrustSetAnchorCertificates (Handle, certs.Handle); } }
public SecStatusCode SetAnchorCertificates (X509Certificate2Collection certificates) { if (Handle == IntPtr.Zero) throw new ObjectDisposedException ("SecTrust"); if (certificates == null) return SecTrustSetAnchorCertificates (Handle, IntPtr.Zero); SecCertificate[] array = new SecCertificate [certificates.Count]; int i = 0; foreach (var certificate in certificates) array [i++] = new SecCertificate (certificate); return SetAnchorCertificates (array); }
void Initialize (SecCertificate[] array, SecPolicy policy) { using (var certs = CFArray.FromNativeObjects (array)) { Initialize (certs.Handle, policy); } }
public static SecStatusCode TryQueryAsConcreteType(SecRecord query, out object result) { if (query == null){ result = null; return SecStatusCode.Param; } using (var copy = NSMutableDictionary.FromDictionary (query.queryDict)){ copy.SetObject (CFBoolean.TrueObject, SecItem.ReturnRef); IntPtr ptr; var ret = SecItem.CopyMatching (copy, out ptr); if (ret == SecStatusCode.Success){ int cfType = CFType.GetTypeID (ptr); if (cfType == SecCertificate.GetTypeID ()) result = new SecCertificate (ptr, true); else if (cfType == SecKey.GetTypeID ()) result = new SecKey (ptr, true); else if (cfType == SecIdentity.GetTypeID ()) result = new SecIdentity (ptr, true); else throw new Exception (String.Format ("Unexpected type: 0x{0:x}", ret)); result = null; } else result = null; return ret; } }