Exemple #1
0
        public SecTrust(SecCertificate certificate, SecPolicy policy)
        {
            if (certificate == null)
                throw new ArgumentNullException ("certificate");

            Initialize (certificate.Handle, policy);
        }
Exemple #2
0
        public static NSUrlCredential FromIdentityCertificatesPersistance(SecIdentity identity, SecCertificate [] certificates, NSUrlCredentialPersistence persistence)
        {
            if (identity == null)
                throw new ArgumentNullException ("identity");

            if (certificates == null)
                throw new ArgumentNullException ("certificates");

            using (var certs = NSArray.FromNativeObjects (certificates))
                return FromIdentityCertificatesPersistanceInternal (identity.Handle, certs.Handle, persistence);
        }
Exemple #3
0
 public MCSession(MCPeerID myPeerID, SecIdentity identity, SecCertificate[] certificates, MCEncryptionPreference encryptionPreference)
     : base(NSObjectFlag.Empty)
 {
     if (identity == null) {
         if (certificates == null)
             Handle = Init (myPeerID, null, encryptionPreference);
         else
             throw new ArgumentNullException ("identity");
     } else {
         using (var certs = NSArray.FromNativeObjects (certificates))
             Handle = Init (myPeerID, certs, encryptionPreference);
     }
 }
Exemple #4
0
        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);
            }
        }
Exemple #5
0
 public NSUrlCredential(SecIdentity identity, SecCertificate [] certificates, NSUrlCredentialPersistence persistence)
     : this(identity.Handle, NSArray.FromNativeObjects (certificates).Handle, persistence)
 {
 }
Exemple #6
0
		internal static bool Equals (SecCertificate first, SecCertificate second)
		{
			/*
			 * This is a little bit expensive, but unfortunately there is no better API to compare two
			 * SecCertificateRef's for equality.
			 */
			if (first == null)
				throw new ArgumentNullException ("first");
			if (second == null)
				throw new ArgumentNullException ("second");
			if (first.Handle == second.Handle)
				return true;

			using (var firstData = first.DerData)
			using (var secondData = second.DerData) {
				if (firstData.Handle == secondData.Handle)
					return true;

				if (firstData.Length != secondData.Length)
					return false;
				nint length = (nint)firstData.Length;
				for (nint i = 0; i < length; i++) {
					if (firstData [i] != secondData [i])
						return false;
				}

				return true;
			}
		}
Exemple #7
0
 public SecStatusCode SetAnchorCertificates(SecCertificate[] array)
 {
     if (array == null)
         return SecTrustSetAnchorCertificates (handle, IntPtr.Zero);
     using (var certs = CFArray.FromNativeObjects (array)) {
         return SecTrustSetAnchorCertificates (handle, certs.Handle);
     }
 }
Exemple #8
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);
        }
Exemple #9
0
        public SecTrust(X509Certificate2Collection 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);
        }
Exemple #10
0
        public SecTrust(X509Certificate2 certificate, SecPolicy policy)
        {
            if (certificate == null)
                throw new ArgumentNullException ("certificate");

            using (SecCertificate cert = new SecCertificate (certificate)) {
                Initialize (cert.Handle, policy);
            }
        }
Exemple #11
0
 void Initialize(SecCertificate[] array, SecPolicy policy)
 {
     using (var certs = CFArray.FromNativeObjects (array)) {
         Initialize (certs.Handle, policy);
     }
 }