Пример #1
0
        public void Dispose()
        {
            if (!_isDisposed)
            {
                if (_useCertificateBundle)
                {
                    CertificateBundleUtilities.RemoveCertificateFromBundle(_certificateBundle, Certificate);
                }

                X509StoreUtilities.RemoveCertificateFromStore(StoreLocation, StoreName, Certificate);

                Certificate.Dispose();

                GC.SuppressFinalize(this);

                _isDisposed = true;
            }
        }
Пример #2
0
        public X509StoreCertificate(StoreLocation storeLocation, StoreName storeName, X509Certificate2 certificate, FileInfo certificateBundle = null)
        {
            if (certificate is null)
            {
                throw new ArgumentNullException(nameof(certificate));
            }

            StoreLocation      = storeLocation;
            StoreName          = storeName;
            Certificate        = certificate;
            _certificateBundle = certificateBundle;

            _useCertificateBundle = storeName == StoreName.Root && !RuntimeEnvironmentHelper.IsWindows;

            if (_useCertificateBundle)
            {
                CertificateBundleUtilities.AddCertificateToBundle(certificateBundle, certificate);
            }

            // Some tests perform in-process signing and verification.
            // Other tests first create a signed package in-process and then verify out of process using the dotnet CLI.
            // So, the in-process test fallback certificate store must always be updated.
            X509StoreUtilities.AddCertificateToStore(storeLocation, storeName, certificate);
        }