下面的方法只有在你要Export的证书保存在系统KeyStore的情况下才适用:
1. 如果需要整个用户界面的话,可以再你的程序中激活CertMgr.exe,或者适用
   CertMgr.exe -put
   命令导出证书。
2. 可以调用API: PFXExportCertStoreEx
   取的证书的二进制表示,然后自己存盘。另外,可能你也可以使用CryptoAPI COM Wrapper(在MSDN查找CAPCOM)。

解决方案 »

  1.   

    恩,谢谢老大们.我的具体问题是这样的,我有一大堆证书放在我的个人存储区中,我想从中导出一个名为"liu"的带私钥的证书.私钥密码为"liuliu"我想让我的应用程序不显示这段导出过程.(包括密码也不要手动输入)而完成这个任务,请给出一段代码.....谢谢
      

  2.   

    请关注的朋友继续关注,up的朋友继续up.我必须5.1之前把它搞完。。急!!
      

  3.   

    有Windows API可用的吧,略微浏览了一下几个函数,没用过
      

  4.   

    前面不是说了可以调PFXExportCertStoreEx吗?
      

  5.   

    唉..谁能先教我在C#里面用windows api的方法阿??我在csdn 上只有vb的演练。。我在c#上不会用啊
      

  6.   

    糊涂了,你说的证书是什么证书?是应用程序自身的证书还是windows user 证书、domain user 证书、签名还是
      

  7.   

    就是那种可以导出来又可以导进去的证书拉。用于数字签名的
    PFXExportCertStoreEx在哪个 .dll里呀??
      

  8.   

    我搞不懂这些参数的类型。请解释一下好吗
    BOOL WINAPI PFXExportCertStoreEx(
      HCERTSTORE hStore, ------这个我知道是  IntPtr                     
      CRYPT_DATA_BLOB *pPFX,
      LPCWSTR szPassword,        ---这个是 string
      void *pvReserved,
      DWORD dwFlags
    );
    其余呢????
      

  9.   

    PFXExportCertStoreEx
    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
      

  10.   

    55555555这一页我已经看了很长时间了,就是看不懂啊。。现在就是这个c#中调api 比较闹心PFXExportCertStoreEx 这个到底如何用啊
      

  11.   

    [DllImport("crypt32.dll", EntryPoint="PFXExportCertStoreEx",  charSet=CharSet.Auto)] 
      public  static extern int  eee(IntPtr hStore,string szPassword,UInt32 dwFlags); 我现在只能知道 hStore 用 Intptr;  用 .handle获得
    szPassword 用 string 就可以; 还有 dwFlags 可能用 UInt32;
    其余的几个都不会 而且只知道hStore 用.handle 得到, szPassword 字符串就可以了
    其余的连懂都不懂