상속: INativeObject, IDisposable
예제 #1
0
파일: Trust.cs 프로젝트: polipo/maccore
		public SecTrust (X509Certificate2 certificate, SecPolicy policy)
		{
			if (certificate == null)
				throw new ArgumentNullException ("certificate");

			using (SecCertificate cert = new SecCertificate (certificate)) {
				Initialize (cert.Handle, policy);
			}
		}
예제 #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);
        }
예제 #3
0
파일: Trust.cs 프로젝트: Terricide/monomac
        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));
        }
예제 #4
0
파일: Trust.cs 프로젝트: polipo/maccore
		SecStatusCode SetAnchorCertificates (SecCertificate[] array)
		{
			using (var certs = CFArray.FromNativeObjects (array)) {
				return SecTrustSetAnchorCertificates (Handle, certs.Handle);
			}
		}
예제 #5
0
파일: Trust.cs 프로젝트: polipo/maccore
		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);
		}
예제 #6
0
파일: Trust.cs 프로젝트: polipo/maccore
		void Initialize (SecCertificate[] array, SecPolicy policy)
		{
			using (var certs = CFArray.FromNativeObjects (array)) {
				Initialize (certs.Handle, policy);
			}
		}
예제 #7
0
파일: Items.cs 프로젝트: kangaroo/maccore
        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;
            }
        }