首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用SmartCard签署PDF文件

使用SmartCard签署PDF文件
EN

Stack Overflow用户
提问于 2022-02-16 12:23:29
回答 1查看 292关注 0票数 1

我曾尝试用一张智能卡与Node、、chilkat、签署pdf,但都失败了。当我把智能卡安装在我的电脑上时,我发现了这个错误,然后我执行我的代码:我找不到最好的解决方案。

代码语言:javascript
复制
> 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

另外:当我运行这段代码时:

代码语言:javascript
复制
    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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-16 17:27:15

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

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71141816

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档