public void Remove(ICertificatePal certPal) { if (!Directory.Exists(_storePath)) { return; } OpenSslX509CertificateReader cert = (OpenSslX509CertificateReader)certPal; using (X509Certificate2 copy = new X509Certificate2(cert.DuplicateHandles())) { string?currentFilename; do { bool hadCandidates; currentFilename = FindExistingFilename(copy, _storePath, out hadCandidates); if (currentFilename != null) { if (_readOnly) { // Windows compatibility, the readonly check isn't done until after a match is found. throw new CryptographicException(SR.Cryptography_X509_StoreReadOnly); } File.Delete(currentFilename); ChainPal.FlushStores(); } } while (currentFilename != null); } }
public void Add(ICertificatePal certPal) { if (_readOnly) { // Windows compatibility: Remove only throws when it needs to do work, add throws always. throw new CryptographicException(SR.Cryptography_X509_StoreReadOnly); } try { AddCertToStore(certPal); ChainPal.FlushStores(); } catch (CryptographicException) { throw; } catch (Exception e) { throw new CryptographicException(SR.Cryptography_X509_StoreAddFailure, e); } }