Questions about PKCS11

Hi,Everybody,

when I try to access smartcard by pkcs11 ,I got a problem

the exception is :

--Exception in thread "main" java.security.ProviderException: SunPKCS11 requires configuration file argument

and my code :

public class Test {

public static void main(String[] args) {

String strPth = "C:/pkcs11.cfg";

Provider pkcs11Provider =

new sun.security.pkcs11.SunPKCS11(strPth);

Security.addProvider(pkcs11Provider);

System.out.println("success");

}

}

the pkcs11.cfg file :

name = SmartCard

library = C:/windows/system32/drivers/wdpkc.dll

Can anybody help me?

Thanks

[681 byte] By [Iceberg05a] at [2007-11-27 9:51:22]
# 1

The Whole Exceptions:

Exception in thread "main" java.security.ProviderException: SunPKCS11 requires configuration file argument

at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:71)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at java.lang.Class.newInstance0(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at sun.security.jca.ProviderConfig$3.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at sun.security.jca.ProviderConfig.doLoadProvider(Unknown Source)

at sun.security.jca.ProviderConfig.getProvider(Unknown Source)

at sun.security.jca.ProviderList.loadAll(Unknown Source)

at sun.security.jca.ProviderList.removeInvalid(Unknown Source)

at sun.security.jca.Providers.getFullProviderList(Unknown Source)

at java.security.Security.insertProviderAt(Unknown Source)

at java.security.Security.addProvider(Unknown Source)

at src.Test.main(Test.java:96)

Message was edited by:

Iceberg05

Iceberg05a at 2007-7-13 0:20:27 > top of Java-index,Security,Cryptography...
# 2

Not sure whose smartcard this is, but typically you need more than just the name of the smartcard slot and driver information in the configuration file; the values depend on the implementation of the PKCS11 driver from the manufacturer.

The source code in StrongKey (www.strongkey.org) has a configuration file for a GemPlus smartcard, as well as for the Mozilla PKCS11 software token. Use them as examples of the type of information you might need for your own driver, but check with your smartcard manufacturer for the definitive information.

arshad.noora at 2007-7-13 0:20:27 > top of Java-index,Security,Cryptography...
# 3
Thanks for your answer.Yesterday, I recombiled my code in a entirely clear Eclipse IDE, and the code was executed successfully. In fact, I did not change anything on the code. So , I think, maybe there were something wrong with my eclipse`s enviroment variables.
Iceberg05a at 2007-7-13 0:20:27 > top of Java-index,Security,Cryptography...