Inheritance: INativeObject, IDisposable
Beispiel #1
0
		public SecTrust (X509Certificate2 certificate, SecPolicy policy)
		{
			if (certificate == null)
				throw new ArgumentNullException ("certificate");

			using (SecCertificate cert = new SecCertificate (certificate)) {
				Initialize (cert.Handle, policy);
			}
		}
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
		SecStatusCode SetAnchorCertificates (SecCertificate[] array)
		{
			using (var certs = CFArray.FromNativeObjects (array)) {
				return SecTrustSetAnchorCertificates (Handle, certs.Handle);
			}
		}
Beispiel #5
0
		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);
		}
Beispiel #6
0
		void Initialize (SecCertificate[] array, SecPolicy policy)
		{
			using (var certs = CFArray.FromNativeObjects (array)) {
				Initialize (certs.Handle, policy);
			}
		}
Beispiel #7
0
        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;
            }
        }