使用智能卡签署 PDF

Sign a PDF using SmartCard

我尝试使用带有 Node JS chilkat 的智能卡对 pdf 进行签名,但失败了。 当我放置智能卡并在我的计算机上安装驱动程序时,我发现了这个错误,然后我执行我的代码: 我找不到最佳解决方案

> TnTrust Token ChilkatLog:   LoadFromSmartcard(123984ms):
>     DllDate: Dec  2 2021
>     ChilkatVersion: 9.5.0.89
>     UnlockPrefix: Auto unlock for 30-day trial
>     Architecture: Little Endian; 64-bit
>     Language: Windows Node.js
>     VerboseLogging: 1
>     NoScminidriver present in UncommonOptions
>       chosenCsp: TnTrust Token
>     --chooseSmartcardLegacyCsp
>     loadFromSmartcard_capi(3078ms):
>       loadSmartcardCert:
>         kcGetKpCertificate:
>           providerName: TnTrust Token
>           bExchangeKey: False
>           WindowsError: Acc�s refus�.
>           WindowsErrorCode: 0x80090010
>         --kcGetKpCertificate
>         retry with opposite choice...
>         kcGetKpCertificate:
>           providerName: TnTrust Token
>           bExchangeKey: True
>           WindowsError: Acc�s refus�.
>           WindowsErrorCode: 0x80090010
>         --kcGetKpCertificate
>         Unable to get the key provider certificate.
>       --loadSmartcardCert
>     --loadFromSmartcard_capi   --LoadFromSmartcard
> --ChilkatLog

还有这个: [![在此处输入图片描述][1]][1] 当我 运行 此代码时:

    var pdf = new chilkat.Pdf();
    var success = pdf.LoadFile("qa_data/pdf/hello.pdf");
    if (success == false) {
        console.log(pdf.LastErrorText);
        return;
    }
    var json = new chilkat.JsonObject();
    json.UpdateInt("signingCertificateV2",1);
    json.UpdateInt("signingTime",1);
    json.UpdateInt("page",1);
    json.UpdateString("appearance.y","top");
    json.UpdateString("appearance.x","left");
    json.UpdateString("appearance.fontScale","10.0");

    json.UpdateString("appearance.text[0]","Digitally signed by: cert_cn");
    json.UpdateString("appearance.text[1]","current_dt");
    var cert = new chilkat.Cert();
cert.UncommonOptions = "NoScMinidriver"
cspName = "TnTrust Token";
success = cert.LoadFromSmartcard(cspName)
    if (success == false) {
            console.log('TnTrust Token',cert.LastErrorText);
        return;
    }
    cert.SmartCardPin = "123456";
    success = pdf.SetSigningCert(cert);
    if (success == false) {
        console.log(pdf.LastErrorText);
        return;
    }
    success = pdf.SignPdf(json,"qa_output/hello_signed_hsm.pdf");
    if (success == false) {
        console.log(pdf.LastErrorText);
        return;
    }
    console.log("The PDF has been successfully cryptographically signed using an HSM.");
}

chilkatExample();```
thanks. 

  [1]: https://i.stack.imgur.com/11EwM.png

我在这里上传了一个新版本:https://www.npmjs.com/package/@chilkat/ck-node14-win64 它是版本“9.50.89-hotfix1”。

请试一试。另外,我看到您正在将“TnTrust 令牌”传递给 LoadFromSmartCard。如果问题仍然存在,请尝试传递一个空字符串。这应该会导致 Chilkat 尝试使用默认的 Microsoft CNG 存储提供程序,这可能会更成功。