Forum Stats

  • 3,838,508 Users
  • 2,262,377 Discussions
  • 7,900,674 Comments

Discussions

CAC applet unable to find acpkcs211.dll

colerick
colerick Member Posts: 38
edited Nov 20, 2013 10:45AM in Cryptography

I'm required to develop an applet that can call the ActivClient dll to read a CAC smartcard.

I have a working console version that works perfectly as it references a locally stored config file with the following:

name = myConfig

library = C:\Windows\System32\acpkcs211.dll

but in the applet implementation that config file wouldn't exist on each of the clients.  The actual DLL of course would be required to. 

I'm not much of a java or applet developer. Was handed the working console code and told to make an applet that worked.

How do I access the dll from the signed, Java 1.7, Permissions: all-permissions applet?  I tried the following:

String configName = "name = myConfig"+System.getProperty("line.separator")+"library = C:\\Windows\\System32\\acpkcs211.dll";

acProvider = new sun.security.pkcs11.SunPKCS11(configName);

Security.addProvider(acProvider);

Start of CACActivApplet
java.security.ProviderException: Error parsing configuration
    at sun.security.pkcs11.Config.getConfig(Config.java:88)
    at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:128)
    at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:103)
    at CACReader.CACReaderActivClient.<init>(CACReaderActivClient.java:91)
    at CACActivApplet.init(CACActivApplet.java:54)
    at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: name = myConfig
library = acpkcs211.dll (The filename, directory name, or volume label syntax is incorrect)
    at java.io.FileInputStream.open(Native Method)

I'm launching it from an SSL'd webserver with the following html.

<body>
<applet id="CACApplet" code = "CACActivApplet"
    archive = "CACApplet.jar"
    width = 725
    height = 300>
    <param name="permissions" value="all-permissions" />
</applet>
</body>

Thanks in advance

Answers

  • 1055801
    1055801 Member Posts: 2

    There is one problem I see here.  You are supposed to pass config file name with full path to  constructor of  sun.security.pkcs11.SunPKCS11 .

    For example:

    String configName = "c:/MyDir/pkcs11.cfg";

    Provider p = new sun.security.pkcs11.SunPKCS11(configName);

    Security.addProvider(p);

    Where  pkcs11.cfg content will be this

    name = myConfig

    library = C:\Windows\System32\acpkcs211.dll

    Please refer the following page for more deatils : Java PKCS#11 Reference Guide

    Thanks,

    Raghu Nair

  • colerick
    colerick Member Posts: 38

    Yes, that's the problem. In my console app, that is how it works but in an applet that is called from the web, I can't expect that file to exist on every (or even any) client system, can I?  I'd found a post that suggested creating it during execution without actually writing it to the filesystem by using:

    String configName = "name = myConfig"+System.getProperty("line.separator")+"library = C:\\Windows\\System32\\acpkcs211.dll";

    but it doesn't seem to work (maybe it did in an older version of java).  Maybe I could store the config file and/or even the dll inside my applet jar file but I'm not sure how to then reference it.

This discussion has been closed.