public CopyTo ( |
||
collection | ||
return | void |
public void FindAndCopyTo(X509FindType findType, object findValue, bool validOnly, X509Certificate2Collection collection) { Debug.Assert(collection != null); StorePal findResults = CreatedLinkedStoreWithFindResults(findType, findValue, validOnly); findResults.CopyTo(collection); }
private unsafe void FindCore(CertFindType dwFindType, void *pvFindPara, Func <SafeCertContextHandle, bool>?filter = null) { SafeCertStoreHandle findResults = Interop.crypt32.CertOpenStore( CertStoreProvider.CERT_STORE_PROV_MEMORY, CertEncodingType.All, IntPtr.Zero, CertStoreFlags.CERT_STORE_ENUM_ARCHIVED_FLAG | CertStoreFlags.CERT_STORE_CREATE_NEW_FLAG, null); if (findResults.IsInvalid) { throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); } SafeCertContextHandle?pCertContext = null; while (Interop.crypt32.CertFindCertificateInStore(_storePal.SafeCertStoreHandle, dwFindType, pvFindPara, ref pCertContext)) { if (filter != null && !filter(pCertContext)) { continue; } if (_validOnly) { if (!VerifyCertificateIgnoringErrors(pCertContext)) { continue; } } if (!Interop.crypt32.CertAddCertificateLinkToStore(findResults, pCertContext, CertStoreAddDisposition.CERT_STORE_ADD_ALWAYS, IntPtr.Zero)) { throw Marshal.GetLastWin32Error().ToCryptographicException(); } } using (StorePal resultsStore = new StorePal(findResults)) { resultsStore.CopyTo(_copyTo); } }
private unsafe void FindCore(CertFindType dwFindType, void* pvFindPara, Func<SafeCertContextHandle, bool> filter = null) { SafeCertStoreHandle findResults = Interop.crypt32.CertOpenStore( CertStoreProvider.CERT_STORE_PROV_MEMORY, CertEncodingType.All, IntPtr.Zero, CertStoreFlags.CERT_STORE_ENUM_ARCHIVED_FLAG | CertStoreFlags.CERT_STORE_CREATE_NEW_FLAG, null); if (findResults.IsInvalid) throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); SafeCertContextHandle pCertContext = null; while (Interop.crypt32.CertFindCertificateInStore(_storePal.SafeCertStoreHandle, dwFindType, pvFindPara, ref pCertContext)) { if (filter != null && !filter(pCertContext)) continue; if (_validOnly) { if (!VerifyCertificateIgnoringErrors(pCertContext)) continue; } if (!Interop.crypt32.CertAddCertificateLinkToStore(findResults, pCertContext, CertStoreAddDisposition.CERT_STORE_ADD_ALWAYS, IntPtr.Zero)) throw Marshal.GetLastWin32Error().ToCryptographicException(); } using (StorePal resultsStore = new StorePal(findResults)) { resultsStore.CopyTo(_copyTo); } }