下面的方法只有在你要Export的证书保存在系统KeyStore的情况下才适用:
1. 如果需要整个用户界面的话,可以再你的程序中激活CertMgr.exe,或者适用
CertMgr.exe -put
命令导出证书。
2. 可以调用API: PFXExportCertStoreEx
取的证书的二进制表示,然后自己存盘。另外,可能你也可以使用CryptoAPI COM Wrapper(在MSDN查找CAPCOM)。
1. 如果需要整个用户界面的话,可以再你的程序中激活CertMgr.exe,或者适用
CertMgr.exe -put
命令导出证书。
2. 可以调用API: PFXExportCertStoreEx
取的证书的二进制表示,然后自己存盘。另外,可能你也可以使用CryptoAPI COM Wrapper(在MSDN查找CAPCOM)。
PFXExportCertStoreEx在哪个 .dll里呀??
BOOL WINAPI PFXExportCertStoreEx(
HCERTSTORE hStore, ------这个我知道是 IntPtr
CRYPT_DATA_BLOB *pPFX,
LPCWSTR szPassword, ---这个是 string
void *pvReserved,
DWORD dwFlags
);
其余呢????
The PFXExportCertStoreEx function exports the certificates and, if available, their associated private keys from the referenced certificate store. This function replaces the older PfxExportCertStore function. It should be used for its enhanced private key security.BOOL WINAPI PFXExportCertStoreEx(
HCERTSTORE hStore,
CRYPT_DATA_BLOB *pPFX,
LPCWSTR szPassword,
void *pvReserved,
DWORD dwFlags
);
Parameters
hStore
[in] Handle of the certificate store containing the certificates to be exported.
pPFX
[in/out] Pointer to a CRYPT_DATA_BLOB structure to contain the PFX packet with the exported certificates and keys. If pPFX->pbData is NULL, the function calculates the number of bytes needed for the encoded BLOB and returns this in pPFX->cbData. When the function is called with pPFX-pdData pointing an allocated buffer of the needed size, the function copies the encoded bytes into the buffer and updates pPFX->cbData with the encode byte length.
szPassword
[in] String password used to encrypt and verify the PFX packet.
pvReserved
[reserved] Reserved for future use. Currently, this parameter must be NULL.
dwFlags
[in] Flag values can be set to any combination of the following. Flag Description
EXPORT_PRIVATE_KEYS Private keys are exported as well as the certificates.
REPORT_NO_PRIVATE_KEY If a certificate is encountered that has no associated private key, the function returns FALSE with the last error set to either CRYPT_E_NOT_FOUND or NTE_NO_KEY.
REPORT_NOT_ABLE_TO_EXPORT_PRIVATE_KEY If a certificate is encountered that has a non-exportable private key, the function returns FALSE with the last error set to either CRYPT_E_NOT_FOUND or NTE_BAD_KEY.
Return Values
Returns TRUE (non-zero) if the function succeeds, and FALSE (zero) if the function fails. For extended error information, call GetLastError.check msdn:ms-help://MS.VSCC/MS.MSDNVS.2052/security/cryptoref2_3s8o.htm
public static extern int eee(IntPtr hStore,string szPassword,UInt32 dwFlags); 我现在只能知道 hStore 用 Intptr; 用 .handle获得
szPassword 用 string 就可以; 还有 dwFlags 可能用 UInt32;
其余的几个都不会 而且只知道hStore 用.handle 得到, szPassword 字符串就可以了
其余的连懂都不懂