简体   繁体   English

使用ukey上的密钥/证书对数据进行签名

[英]Use key / certificate on ukey to sign data

I want to get certificate from ukey, and sign data. 我想从ukey获得证书,并签署数据。 Now I can get it, and succeeded in a console application program. 现在,我可以获取它,并成功完成了控制台应用程序。 But when I make it as an OCX control for Internet Explorer then it doesn't work. 但是,当我将其作为Internet Explorer的OCX控件使用时,它将无法正常工作。

When I use the following function: 当我使用以下功能时:

CryptAcquireContext(&hProvder, NULL, my_provder_name, PROV_RSA_FULL, 0)

it fails, returning nte_bad_keyset . 它失败,返回nte_bad_keyset

When I use CRYPT_NEWKEYSET or CRYPT_MACHINE_KEYSET instead of 0 , signing the data fails. 当我使用CRYPT_NEWKEYSETCRYPT_MACHINE_KEYSET而不是0 ,数据签名失败。

How can I create a signature using ukey? 如何使用ukey创建签名?

CryptAcquireContext(&hProvder, NULL, my_provder_name, PROV_RSA_FULL, 0); CryptAcquireContext(&hProvder,NULL,my_provder_name,PROV_RSA_FULL,0);

You want to get the csp which could be helpful for signature your file.In a desktop application,you can use the function with those parameters like that case.But in browser,you can't. 您想获得对签名文件很有帮助的csp。在桌面应用程序中,可以将函数与诸如此类的参数一起使用。但是在浏览器中却不能。 we want to get the default key container associated with the current user. 我们想要获取与当前用户关联的默认密钥容器。 Howerver, when certificates are created, they may be placed in a key container other than the default, so the default container doesn't exist. 但是,创建证书时,可以将它们放置在默认容器之外的其他密钥容器中,因此默认容器不存在。 why? 为什么? The problem appears to stem from the second parameter. 该问题似乎源于第二个参数。 So, we must specify the name of key container as the second parameter. 因此,我们必须指定密钥容器的名称作为第二个参数。 Like this: CryptAcquireContext(&hProvder, container_name, my_provder_name, PROV_RSA_FULL, 0); 像这样:CryptAcquireContext(&hProvder,container_name,my_provder_name,PROV_RSA_FULL,0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM