个人证书用pkcs12格式打包并装入IE里了

解决方案 »

  1.   

    我看了MSDN,但是好像说的不太明确,你用过吗?可以说详细点吗?
      

  2.   

    不知这个是否有点帮助:
    http://www.vckbase.com/document/viewdoc.asp?id=305
      

  3.   

    if(CryptAcquireContext(
        &hCryptProv,        // Address for handle to be returned.
        NULL,               // Use the current user's logon name.
        NULL,               // Use the default provider.
        PROV_RSA_FULL,      // Need to both encrypt and sign.
        NULL))              
    {
    MessageBox(NULL,"quire");
    }
    else
    {
    HandleError("error");
    }if(CryptExportPublicKeyInfo(
              hCryptProv,            // Provider handle
              AT_SIGNATURE,          // Key spec
              MY_ENCODING_TYPE,      // Encoding type
              NULL,                  // pbPublicKeyInfo
              &cbPublicKeyInfo)) 
    {
    MessageBox(NULL,"keyInfo");
    }
    else
    {
    HandleError("error");

    }
    为什么CryptAcquireContext()成功了而CryptExportPublicKeyInfo()会失败呢?调用了HandleError("error");
    if(!( CryptAcquireCertificatePrivateKey(
    pSignerCertContext,
    0,
    NULL,
    &hCryptProv,
    &dwKeySpec,
    NULL)))
    {
    MessageBox(NULL,"private");
    }
    else
    {
    HandleError("error too");
    }
    这个一用就出现异常!
    帮忙看看!
      

  4.   

    //i think you can try this way and get public key,but i don't how to get private key too.
    BOOL CChoose_CertDlg::DoesThisContainerContainThisPubKey(TCHAR
    *strTemp, PCERT_PUBLIC_KEY_INFO pCertPubKeyInfo, DWORD dwKeySpec)
    {
    //check param
    if ( !strTemp )
    return FALSE; HCRYPTPROV hProv = NULL;
    BYTE *pbKeyBlob = NULL;        
    DWORD dwBlobLen = 0;
    DWORD dwCertEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
    PCERT_PUBLIC_KEY_INFO pbPublicKeyInfo = NULL; DWORD dwPubKeyLen = 0;
    BOOL rc = FALSE; __try
    {
    //get the context
    if ( !CryptAcquireContext( &hProv, strTemp, NULL, PROV_RSA_FULL, 0
    ))
    __leave; // Get the public Key, either AT_SIGNATURE or AT_KEYEXCHANGE
    if( !CryptExportPublicKeyInfo(   hProv,  dwKeySpec,
    dwCertEncodingType, NULL, &dwPubKeyLen))
    __leave; // Allocate memory for the pbKeyBlob.
    if(!(pbPublicKeyInfo = (CERT_PUBLIC_KEY_INFO*)malloc(dwPubKeyLen))) 
    __leave; // Do the actual exporting into the key BLOB.
    if( !CryptExportPublicKeyInfo(   hProv,  dwKeySpec,
    dwCertEncodingType, pbPublicKeyInfo, &dwPubKeyLen))
    __leave;

    if ( CertComparePublicKeyInfo( X509_ASN_ENCODING |
    PKCS_7_ASN_ENCODING, pCertPubKeyInfo, pbPublicKeyInfo))
    {
    rc = TRUE;
    __leave;

    }
    __finally
    {
    if ( pbKeyBlob )
    free(pbKeyBlob);
    if(hProv) 
    CryptReleaseContext(hProv, 0);
    } return rc;
    }
      

  5.   

    还有一个问题 jsp调用activex是如何和activex获取的数据进行交换的?<html>
    <body><font size=4>
    <%! String private_key =""; %>
    <OBJECT CLASSID="clsid:F8351667-481E-47E3-ADA6-26A51C4028F4" style="VISIBILITY: hidden" ID="Dgaincert1" VIEWASTEXT codebase="GainCert.ocx">
    </OBJECT>
    <script>
    var priKey =Dgaincert1.getPrivateKey();
    </script>
                      ......
                </body>
    </html>
    怎样可以把priKey赋值给private_key,帮忙!!!