Java安全 - MSCAPI提供者:如何使用没有密码弹出? [英] Java security - MSCAPI provider: How to use without password popup?

查看:324
本文介绍了Java安全 - MSCAPI提供者:如何使用没有密码弹出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功使用 Sun's MSCAPI提供者。我现在的问题是,它总是弹出一个窗口,要求一个密码,即使我已经在代码中提供了。这是一个问题,因为我需要webservice中的加密功能。

I've managed to use Sun's MSCAPI provider in my application. The problem I'm having now is that it always pops up a window, asking for a password, even though I've provided it in the code. This is a problem, because I need the cryptography functionality in a webservice.

这是我现在的代码:

String alias = "Alias to my PK";
char[] pass = "MyPassword".toCharArray();

KeyStore ks = KeyStore.getInstance("Windows-MY");
ks.load(null, pass);
Provider p =  ks.getProvider();

Signature sig = Signature.getInstance("SHA1withRSA",p);
PrivateKey key = (PrivateKey) ks.getKey(alias, pass)

sig.initSign(key);
sig.update("Testing".getBytes());
sig.sign();

这很好用,但是当最后一行运行时,我会弹出一个弹出窗口询问密码。

This is working great, but I get a popup asking for the password when the last line is run. How do I prevent that?

推荐答案

MSCAPI提供商不支持向CAPI提供密码:

The MSCAPI provider does not support providing the password to CAPI:


假设必须提供密码的应用程序支持兼容模式。它允许(但忽略)一个非空密码。默认情况下启用该模式。 (1)

要通过CAPI设置密码,必须调用 CryptSetKeyParam 与未记录的KP_KEYEXCHANGE_PIN或KP_SIGNATURE_PIN,并希望您的底层硬件令牌提供程序支持它。 (它们不是完全未记录的 - Windows CE和Windows Mobile的文档提及它们( 2),它们包含在头文件中)。

To set the password through CAPI, you must call CryptSetKeyParam with the undocumented KP_KEYEXCHANGE_PIN or KP_SIGNATURE_PIN and hope your underlying hardware token provider supports it. (They are not completely undocumented - the documentation for Windows CE and Windows Mobile mention them (2) and they are included in the header files).

这篇关于Java安全 - MSCAPI提供者:如何使用没有密码弹出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆