internal static IntPtr CertEnumCertificatesInStore([In] System.Security.Cryptography.SafeCertStoreHandle hCertStore, [In] IntPtr pPrevCertContext) { if (hCertStore == null) { throw new ArgumentNullException("hCertStore"); } if (hCertStore.IsInvalid) { throw new CryptographicException(SR.GetString("Cryptography_InvalidHandle"), "hCertStore"); } if (pPrevCertContext == IntPtr.Zero) { new StorePermission(StorePermissionFlags.EnumerateCertificates).Demand(); } IntPtr pCertContext = CAPIUnsafe.CertEnumCertificatesInStore(hCertStore, pPrevCertContext); if (pCertContext == IntPtr.Zero) { int hr = Marshal.GetLastWin32Error(); if (hr != -2146885628) { CAPISafe.CertFreeCertificateContext(pCertContext); throw new CryptographicException(hr); } } return(pCertContext); }
internal static System.Security.Cryptography.SafeCertContextHandle CertEnumCertificatesInStore([In] System.Security.Cryptography.SafeCertStoreHandle hCertStore, [In] System.Security.Cryptography.SafeCertContextHandle pPrevCertContext) { if (hCertStore == null) { throw new ArgumentNullException("hCertStore"); } if (hCertStore.IsInvalid) { throw new CryptographicException(SR.GetString("Cryptography_InvalidHandle"), "hCertStore"); } if (pPrevCertContext.IsInvalid) { new StorePermission(StorePermissionFlags.EnumerateCertificates).Demand(); } System.Security.Cryptography.SafeCertContextHandle handle = CAPIUnsafe.CertEnumCertificatesInStore(hCertStore, pPrevCertContext); if (((handle == null) || handle.IsInvalid) && (Marshal.GetLastWin32Error() != -2146885628)) { throw new CryptographicException(Marshal.GetLastWin32Error()); } return(handle); }