Exemplo n.º 1
0
        public X509Certificate2Impl Import(
            byte[] data, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags,
            CertificateImportFlags importFlags = CertificateImportFlags.None)
        {
            if (data == null || data.Length == 0)
            {
                return(null);
            }

            X509Certificate2Impl impl = null;

            if ((importFlags & CertificateImportFlags.DisableNativeBackend) == 0)
            {
                impl = X509Pal.Import(data, password, keyStorageFlags);
                if (impl != null)
                {
                    return(impl);
                }
            }

            if ((importFlags & CertificateImportFlags.DisableAutomaticFallback) != 0)
            {
                return(null);
            }

            return(X509Pal.ImportFallback(data, password, keyStorageFlags));
        }
Exemplo n.º 2
0
        public X509Certificate2Impl Import(
            X509Certificate cert, CertificateImportFlags importFlags = CertificateImportFlags.None)
        {
            if (cert.Impl == null)
            {
                return(null);
            }

            X509Certificate2Impl impl = null;

            if ((importFlags & CertificateImportFlags.DisableNativeBackend) == 0)
            {
                impl = X509Pal.Import(cert);
                if (impl != null)
                {
                    return(impl);
                }
            }

            impl = cert.Impl as X509Certificate2Impl;
            if (impl != null)
            {
                return((X509Certificate2Impl)impl.Clone());
            }

            if ((importFlags & CertificateImportFlags.DisableAutomaticFallback) != 0)
            {
                return(null);
            }

            return(X509Pal.ImportFallback(cert.GetRawCertData()));
        }
Exemplo n.º 3
0
 void MustFallback()
 {
     if (disallowFallback)
     {
         throw new InvalidOperationException();
     }
     if (fallback != null)
     {
         return;
     }
     fallback = X509Helper2.Import(GetRawCertData(), null, X509KeyStorageFlags.DefaultKeySet, true);
 }
Exemplo n.º 4
0
 void MustFallback()
 {
     if (disallowFallback)
     {
         throw new InvalidOperationException();
     }
     if (fallback != null)
     {
         return;
     }
     fallback = SystemDependencyProvider.Instance.CertificateProvider.Import(
         GetRawCertData(), null, X509KeyStorageFlags.DefaultKeySet,
         CertificateImportFlags.DisableNativeBackend);
 }