private static unsafe CertificateStoreHandle OpenSystemStoreWrapper(StoreName storeName) { uint flags = (uint)StoreOpenFlags.NoCryptRelease; if (storeName == StoreName.SPC) { flags |= (uint)SystemStoreLocation.LocalMachine; } else flags |= (uint)SystemStoreLocation.CurrentUser; fixed(char *name = storeName.ToString()) { CertificateStoreHandle store = Imports.CertOpenStore( lpszStoreProvider: (IntPtr)StoreProvider.System, dwMsgAndCertEncodingType: 0, hCryptProv: IntPtr.Zero, dwFlags: flags, pvPara: (IntPtr)name); return(store); } }
unsafe private static CertificateStoreHandle OpenSystemStoreWrapper(StoreName storeName) { uint flags = (uint)StoreOpenFlags.CERT_STORE_NO_CRYPT_RELEASE_FLAG; if (storeName == StoreName.SPC) { flags |= (uint)SystemStoreLocation.CERT_SYSTEM_STORE_LOCAL_MACHINE; } else flags |= (uint)SystemStoreLocation.CERT_SYSTEM_STORE_CURRENT_USER; fixed(char *name = storeName.ToString()) { CertificateStoreHandle store = Imports.CertOpenStore( lpszStoreProvider: (IntPtr)StoreProvider.CERT_STORE_PROV_SYSTEM, dwMsgAndCertEncodingType: 0, hCryptProv: IntPtr.Zero, dwFlags: flags, pvPara: (IntPtr)name); return(store); } }
internal static extern bool PFXExportCertStoreEx( CertificateStoreHandle hStore, IntPtr pPFX, IntPtr szPassword, IntPtr pvReserved, PfxExportFlags dwFlags);
internal static extern bool CertAddCertificateContextToStore( CertificateStoreHandle hCertStore, CertificateHandle pCertContext, AddDisposition dwAddDisposition, [Out] out CertificateHandle ppStoreContext);