[英]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
還有這個: [:[enter image description here][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 存儲提供程序,這可能會更成功。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.