Inheritance: ICollection, IEnumerable
 private X509CertificateClaimSet(X509ChainElementCollection elements, int index)
 {
     this.expirationTime = System.IdentityModel.SecurityUtils.MinUtcDateTime;
     this.elements = elements;
     this.index = index;
     this.certificate = elements[index].Certificate;
 }
コード例 #2
0
 public X509Chain(bool useMachineContext)
 {
     m_status                 = 0;
     m_chainPolicy            = null;
     m_chainStatus            = null;
     m_chainElementCollection = new X509ChainElementCollection();
     m_safeCertChainHandle    = SafeCertChainHandle.InvalidHandle;
     m_useMachineContext      = useMachineContext;
 }
コード例 #3
0
 public X509Chain(bool useMachineContext)
 {
     this.m_syncRoot               = new object();
     this.m_status                 = 0;
     this.m_chainPolicy            = null;
     this.m_chainStatus            = null;
     this.m_chainElementCollection = new X509ChainElementCollection();
     this.m_safeCertChainHandle    = SafeCertChainHandle.InvalidHandle;
     this.m_useMachineContext      = useMachineContext;
 }
コード例 #4
0
 public X509Chain(bool useMachineContext)
 {
     this.m_syncRoot = new object();
     this.m_status = 0;
     this.m_chainPolicy = null;
     this.m_chainStatus = null;
     this.m_chainElementCollection = new X509ChainElementCollection();
     this.m_safeCertChainHandle = SafeCertChainHandle.InvalidHandle;
     this.m_useMachineContext = useMachineContext;
 }
コード例 #5
0
 public void Reset()
 {
     m_status                 = 0;
     m_chainStatus            = null;
     m_chainElementCollection = new X509ChainElementCollection();
     if (!m_safeCertChainHandle.IsInvalid)
     {
         m_safeCertChainHandle.Dispose();
         m_safeCertChainHandle = SafeCertChainHandle.InvalidHandle;
     }
 }
コード例 #6
0
        internal static bool IsSelfSigned(X509Chain chain)
        {
            X509ChainElementCollection chainElements = chain.ChainElements;

            if (chainElements.Count != 1)
            {
                return(false);
            }
            X509Certificate2 certificate = chainElements[0].Certificate;

            return(string.Compare(certificate.SubjectName.Name, certificate.IssuerName.Name, StringComparison.OrdinalIgnoreCase) == 0);
        }
コード例 #7
0
        private void Reset()
        {
            _lazyChainStatus = null;
            _chainElements   = new X509ChainElementCollection();

            IChainPal pal = _pal;

            _pal = null;
            if (pal != null)
            {
                pal.Dispose();
            }
        }
コード例 #8
0
 private unsafe void Init()
 {
     using (SafeCertChainHandle handle = CAPISafe.CertDuplicateCertificateChain(this.m_safeCertChainHandle))
     {
         CAPIBase.CERT_CHAIN_CONTEXT structure = new CAPIBase.CERT_CHAIN_CONTEXT(Marshal.SizeOf(typeof(CAPIBase.CERT_CHAIN_CONTEXT)));
         uint size = (uint)Marshal.ReadInt32(handle.DangerousGetHandle());
         if (size > Marshal.SizeOf(structure))
         {
             size = (uint)Marshal.SizeOf(structure);
         }
         System.Security.Cryptography.X509Certificates.X509Utils.memcpy(this.m_safeCertChainHandle.DangerousGetHandle(), new IntPtr((void *)&structure), size);
         this.m_status = structure.dwErrorStatus;
         this.m_chainElementCollection = new X509ChainElementCollection(Marshal.ReadIntPtr(structure.rgpChain));
     }
 }
コード例 #9
0
ファイル: X509Chain.cs プロジェクト: vicky1408/runtime
        public void Reset()
        {
            // _chainPolicy is not reset for .NET Framework compat
            _lazyChainStatus   = null;
            _chainElements     = null;
            _useMachineContext = false;

            IChainPal pal = _pal;

            _pal = null;
            if (pal != null)
            {
                pal.Dispose();
            }
        }
コード例 #10
0
ファイル: X509Chain.cs プロジェクト: omajid/corefx
        internal bool Build(X509Certificate2 certificate, bool throwOnException)
        {
            lock (_syncRoot)
            {
                if (certificate == null || certificate.Pal == null)
                {
                    throw new ArgumentException(SR.Cryptography_InvalidContextHandle, nameof(certificate));
                }

                Reset();

                X509ChainPolicy chainPolicy = ChainPolicy;
                _pal = ChainPal.BuildChain(
                    _useMachineContext,
                    certificate.Pal,
                    chainPolicy.ExtraStore,
                    chainPolicy.ApplicationPolicy,
                    chainPolicy.CertificatePolicy,
                    chainPolicy.RevocationMode,
                    chainPolicy.RevocationFlag,
                    chainPolicy.VerificationTime,
                    chainPolicy.UrlRetrievalTimeout
                    );
                if (_pal == null)
                {
                    return(false);
                }

                _chainElements = new X509ChainElementCollection(_pal.ChainElements);

                Exception verificationException;
                bool?     verified = _pal.Verify(chainPolicy.VerificationFlags, out verificationException);
                if (!verified.HasValue)
                {
                    if (throwOnException)
                    {
                        throw verificationException;
                    }
                    else
                    {
                        verified = false;
                    }
                }

                return(verified.Value);
            }
        }
コード例 #11
0
        private unsafe void Init()
        {
            using (SafeCertChainHandle safeCertChainHandle = CAPI.CertDuplicateCertificateChain(m_safeCertChainHandle)) {
                CAPI.CERT_CHAIN_CONTEXT pChain = new CAPI.CERT_CHAIN_CONTEXT(Marshal.SizeOf(typeof(CAPI.CERT_CHAIN_CONTEXT)));
                uint cbSize = (uint)Marshal.ReadInt32(safeCertChainHandle.DangerousGetHandle());
                if (cbSize > Marshal.SizeOf(pChain))
                {
                    cbSize = (uint)Marshal.SizeOf(pChain);
                }

                X509Utils.memcpy(m_safeCertChainHandle.DangerousGetHandle(), new IntPtr(&pChain), cbSize);

                m_status = pChain.dwErrorStatus;
                Debug.Assert(pChain.cChain > 0);
                m_chainElementCollection = new X509ChainElementCollection(Marshal.ReadIntPtr(pChain.rgpChain));
            }
        }
コード例 #12
0
 private X509CertificateClaimSet(X509ChainElementCollection elements, int index)
 {
     _elements = elements;
     _index = index;
     _certificate = elements[index].Certificate;
 }
コード例 #13
0
ファイル: X509Chain.cs プロジェクト: dotnet/corefx
        public void Reset()
        {
            // _chainPolicy is not reset for desktop compat
            _lazyChainStatus = null;
            _chainElements = null;
            _useMachineContext = false;

            IChainPal pal = _pal;
            _pal = null;
            if (pal != null)
                pal.Dispose();
        }
コード例 #14
0
ファイル: X509Chain.cs プロジェクト: dotnet/corefx
 public X509Chain(IntPtr chainContext)
 {
     _pal = ChainPal.FromHandle(chainContext);
     Debug.Assert(_pal != null);
     _chainElements = new X509ChainElementCollection(_pal.ChainElements);
 }
コード例 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X509ChainElementCollectionWrap"/> class.
 /// </summary>
 /// <param name="collection">
 /// The collection.
 /// </param>
 public void Initialize(X509ChainElementCollection collection)
 {
     this.elements = new IX509ChainElement[collection.Count];
     var elementFactory = new X509ChainElementFactory(this.file, this.path);
     for (var i = 0; i < this.elements.Length; i++)
     {
         this.elements[i] = elementFactory.Create(collection[i]);
     }
 }
コード例 #16
0
 X509CertificateClaimSet(X509ChainElementCollection elements, int index)
 {
     this.elements = elements;
     this.index = index;
     this.certificate = elements[index].Certificate;
 }
コード例 #17
0
		internal X509ChainImplBtls ()
		{
			chain = new MonoBtlsX509Chain ();
			elements = new X509ChainElementCollection ();
			policy = new X509ChainPolicy ();
		}
コード例 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X509ChainElementCollectionWrap"/> class.
 /// </summary>
 /// <param name="collection">
 /// The collection of X509ChainElement objects.
 /// </param>
 internal X509ChainElementCollectionWrap(X509ChainElementCollection collection)
 {
     this.Initialize(collection);
 }
コード例 #19
0
ファイル: X509Chain.cs プロジェクト: jmhardison/corefx
        private void Reset()
        {
            _lazyChainStatus = null;
            _chainElements = new X509ChainElementCollection();

            IChainPal pal = _pal;
            _pal = null;
            if (pal != null)
                pal.Dispose();
            return;
        }
コード例 #20
0
ファイル: X509Chain.cs プロジェクト: vicky1408/runtime
 public X509Chain(IntPtr chainContext)
 {
     _pal = ChainPal.FromHandle(chainContext);
     Debug.Assert(_pal != null);
     _chainElements = new X509ChainElementCollection(_pal.ChainElements);
 }
コード例 #21
0
ファイル: X509Chain.cs プロジェクト: vicky1408/runtime
        internal bool Build(X509Certificate2 certificate, bool throwOnException)
        {
            lock (_syncRoot)
            {
                if (certificate == null || certificate.Pal == null)
                {
                    throw new ArgumentException(SR.Cryptography_InvalidContextHandle, nameof(certificate));
                }

                if (_chainPolicy != null && _chainPolicy.CustomTrustStore != null)
                {
                    if (_chainPolicy.TrustMode == X509ChainTrustMode.System && _chainPolicy.CustomTrustStore.Count > 0)
                    {
                        throw new CryptographicException(SR.Cryptography_CustomTrustCertsInSystemMode, nameof(_chainPolicy.TrustMode));
                    }

                    foreach (X509Certificate2 customCertificate in _chainPolicy.CustomTrustStore)
                    {
                        if (customCertificate == null || customCertificate.Handle == IntPtr.Zero)
                        {
                            throw new CryptographicException(SR.Cryptography_InvalidTrustCertificate, nameof(_chainPolicy.CustomTrustStore));
                        }
                    }
                }

                Reset();

                X509ChainPolicy chainPolicy = ChainPolicy;
                _pal = ChainPal.BuildChain(
                    _useMachineContext,
                    certificate.Pal,
                    chainPolicy._extraStore,
                    chainPolicy._applicationPolicy,
                    chainPolicy._certificatePolicy,
                    chainPolicy.RevocationMode,
                    chainPolicy.RevocationFlag,
                    chainPolicy.CustomTrustStore,
                    chainPolicy.TrustMode,
                    chainPolicy.VerificationTime,
                    chainPolicy.UrlRetrievalTimeout
                    );
                if (_pal == null)
                {
                    return(false);
                }

                _chainElements = new X509ChainElementCollection(_pal.ChainElements);

                Exception verificationException;
                bool?     verified = _pal.Verify(chainPolicy.VerificationFlags, out verificationException);
                if (!verified.HasValue)
                {
                    if (throwOnException)
                    {
                        throw verificationException;
                    }
                    else
                    {
                        verified = false;
                    }
                }

                return(verified.Value);
            }
        }
コード例 #22
0
ファイル: X509Chain.cs プロジェクト: jmhardison/corefx
        public bool Build(X509Certificate2 certificate)
        {
            lock (_syncRoot)
            {
                if (certificate == null)
                    throw new ArgumentException(SR.Cryptography_InvalidContextHandle, "certificate");

                Reset();

                X509ChainPolicy chainPolicy = ChainPolicy;
                _pal = ChainPal.BuildChain(
                    false,
                    certificate.Pal,
                    chainPolicy.ExtraStore,
                    chainPolicy.ApplicationPolicy,
                    chainPolicy.CertificatePolicy,
                    chainPolicy.RevocationMode,
                    chainPolicy.RevocationFlag,
                    chainPolicy.VerificationTime,
                    chainPolicy.UrlRetrievalTimeout
                    );
                if (_pal == null)
                    return false;

                _chainElements = new X509ChainElementCollection(_pal.ChainElements);

                Exception verificationException;
                bool? verified = _pal.Verify(chainPolicy.VerificationFlags, out verificationException);
                if (!verified.HasValue)
                    throw verificationException;
                return verified.Value;
            }
        }
コード例 #23
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Security.Cryptography.X509Certificates.X509Chain" /> class specifying a value that indicates whether the machine context should be used.</summary>
 /// <param name="useMachineContext">true to use the machine context; false to use the current user context. </param>
 public X509Chain(bool useMachineContext)
 {
     this.location = ((!useMachineContext) ? StoreLocation.CurrentUser : StoreLocation.LocalMachine);
     this.elements = new X509ChainElementCollection();
     this.policy   = new X509ChainPolicy();
 }
コード例 #24
0
 public X509Chain(bool useMachineContext)
 {
     location = useMachineContext ? StoreLocation.LocalMachine : StoreLocation.CurrentUser;
     elements = new X509ChainElementCollection();
     policy   = new X509ChainPolicy();
 }
コード例 #25
0
 private unsafe void Init()
 {
     using (SafeCertChainHandle handle = CAPISafe.CertDuplicateCertificateChain(this.m_safeCertChainHandle))
     {
         CAPIBase.CERT_CHAIN_CONTEXT structure = new CAPIBase.CERT_CHAIN_CONTEXT(Marshal.SizeOf(typeof(CAPIBase.CERT_CHAIN_CONTEXT)));
         uint size = (uint) Marshal.ReadInt32(handle.DangerousGetHandle());
         if (size > Marshal.SizeOf(structure))
         {
             size = (uint) Marshal.SizeOf(structure);
         }
         System.Security.Cryptography.X509Certificates.X509Utils.memcpy(this.m_safeCertChainHandle.DangerousGetHandle(), new IntPtr((void*) &structure), size);
         this.m_status = structure.dwErrorStatus;
         this.m_chainElementCollection = new X509ChainElementCollection(Marshal.ReadIntPtr(structure.rgpChain));
     }
 }
コード例 #26
0
		public override void Reset ()
		{
			if (certificates != null) {
				foreach (var certificate in certificates)
					certificate.Dispose ();
				certificates = null;
			}
			if (elements != null) {
				elements.Clear ();
				elements = null;
			}
		}
コード例 #27
0
 public void Reset()
 {
     this.m_status = 0;
     this.m_chainStatus = null;
     this.m_chainElementCollection = new X509ChainElementCollection();
     if (!this.m_safeCertChainHandle.IsInvalid)
     {
         this.m_safeCertChainHandle.Dispose();
         this.m_safeCertChainHandle = SafeCertChainHandle.InvalidHandle;
     }
 }
コード例 #28
0
 internal X509ChainElementEnumerator(X509ChainElementCollection chainElements)
 {
     _chainElements = chainElements;
     _current       = -1;
 }
コード例 #29
0
 internal X509ChainElementEnumerator(X509ChainElementCollection chainElements)
 {
     _chainElements = chainElements;
     _current = -1;
 }
コード例 #30
0
        private unsafe void Init () {
            using (SafeCertChainHandle safeCertChainHandle = CAPI.CertDuplicateCertificateChain(m_safeCertChainHandle)) {
                CAPI.CERT_CHAIN_CONTEXT pChain = new CAPI.CERT_CHAIN_CONTEXT(Marshal.SizeOf(typeof(CAPI.CERT_CHAIN_CONTEXT)));
                uint cbSize = (uint) Marshal.ReadInt32(safeCertChainHandle.DangerousGetHandle());
                if (cbSize > Marshal.SizeOf(pChain))
                    cbSize = (uint) Marshal.SizeOf(pChain);

                X509Utils.memcpy(m_safeCertChainHandle.DangerousGetHandle(), new IntPtr(&pChain), cbSize);

                m_status = pChain.dwErrorStatus;
                Debug.Assert(pChain.cChain > 0);
                m_chainElementCollection = new X509ChainElementCollection(Marshal.ReadIntPtr(pChain.rgpChain));
            }
        }
コード例 #31
0
 public X509Chain (bool useMachineContext) {
     m_status = 0;
     m_chainPolicy = null;
     m_chainStatus = null;
     m_chainElementCollection = new X509ChainElementCollection();
     m_safeCertChainHandle = SafeCertChainHandle.InvalidHandle;
     m_useMachineContext = useMachineContext;
 }
コード例 #32
0
ファイル: X509Chain.cs プロジェクト: Profit0004/mono
		public X509Chain (bool useMachineContext) 
		{
			location = useMachineContext ? StoreLocation.LocalMachine : StoreLocation.CurrentUser;
			elements = new X509ChainElementCollection ();
			policy = new X509ChainPolicy ();
		}
コード例 #33
0
 /// <summary>
 /// Wraps the X509ChainElementCollection creation method.
 /// </summary>
 /// <param name="collection">
 /// The collection of X509ChainElement objects.
 /// </param>
 /// <returns>
 /// The <see cref="IX509ChainElementCollection"/>.
 /// </returns>
 public IX509ChainElementCollection Create(X509ChainElementCollection collection)
 {
     return new X509ChainElementCollectionWrap(collection);
 }