Inheritance: INativeObject, IDisposable
Ejemplo n.º 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);
			}
		}
Ejemplo n.º 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);
		}
Ejemplo n.º 3
0
        public SecTrust(X509Certificate2 certificate, SecPolicy policy)
        {
            if (certificate == null)
            {
                throw new ArgumentNullException("certificate");
            }

            using (SecCertificate cert = new SecCertificate(certificate)) {
                Initialize(cert.Handle, policy);
            }
        }
Ejemplo n.º 4
0
        void Initialize(IntPtr certHandle, SecPolicy policy)
        {
            if (policy == null)
            {
                throw new ArgumentNullException("policy");
            }

            SecStatusCode result = SecTrustCreateWithCertificates(certHandle, policy.Handle, out handle);

            if (result != SecStatusCode.Success)
            {
                throw new ArgumentException(result.ToString());
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
		static public SecPolicy CreateSslPolicy (bool server, string hostName)
		{
#if false
			NSString host = hostName == null ? null : new NSString (hostName);
			IntPtr handle = host == null ? IntPtr.Zero : host.Handle; 
			SecPolicy policy = new SecPolicy (SecPolicyCreateSSL (server, handle), true);
			if (host != null)
				host.Dispose ();
#else
			CFString host = hostName == null ? null : new CFString (hostName);
			IntPtr handle = host == null ? IntPtr.Zero : host.Handle; 
			SecPolicy policy = new SecPolicy (SecPolicyCreateSSL (server, handle), true);
			if (host != null)
				host.Dispose ();
#endif
			return policy;
		}
Ejemplo n.º 7
0
        static public SecPolicy CreateSslPolicy(bool server, string hostName)
        {
#if false
            NSString  host   = hostName == null ? null : new NSString(hostName);
            IntPtr    handle = host == null ? IntPtr.Zero : host.Handle;
            SecPolicy policy = new SecPolicy(SecPolicyCreateSSL(server, handle), true);
            if (host != null)
            {
                host.Dispose();
            }
#else
            CFString  host   = hostName == null ? null : new CFString(hostName);
            IntPtr    handle = host == null ? IntPtr.Zero : host.Handle;
            SecPolicy policy = new SecPolicy(SecPolicyCreateSSL(server, handle), true);
            if (host != null)
            {
                host.Dispose();
            }
#endif
            return(policy);
        }
Ejemplo n.º 8
0
		void Initialize (IntPtr certHandle, SecPolicy policy)
		{
			if (policy == null)
				throw new ArgumentNullException ("policy");
			IntPtr handle;
			SecStatusCode result = SecTrustCreateWithCertificates (certHandle, policy.Handle, out handle);
			if (result != SecStatusCode.Success)
				throw new ArgumentException (result.ToString ());
			Handle = handle;
		}
Ejemplo n.º 9
0
		void Initialize (SecCertificate[] array, SecPolicy policy)
		{
			using (var certs = CFArray.FromNativeObjects (array)) {
				Initialize (certs.Handle, policy);
			}
		}
Ejemplo n.º 10
0
 void Initialize(SecCertificate[] array, SecPolicy policy)
 {
     using (var certs = CFArray.FromNativeObjects(array)) {
         Initialize(certs.Handle, policy);
     }
 }