title: java.security.KeyStoreException: PKCS11 not found
body: <p>My goal is to read information from a CAC card and use <code>pkcs11</code> to extract information from it and sign my document. I couldn't find the right dll for my hardware, so I installed <code>openSC</code> on my machine and used <code>opensc-pkcs11.dll</code> in the following code:</p>
  
  <pre><code>String configName = "pkcs.cnf"; //my config file that points to opensc-pkcs11.dll
  String PIN = "123456";
  Provider p = new sun.security.pkcs11.SunPKCS11(configName);
  Security.addProvider(p);
  KeyStore keyStore = KeyStore.getInstance("PKCS11");
  char[] pin = PIN.toCharArray();
  keyStore.load(null, pin);
  </code></pre>
  
  <p>But I'm getting an error at the following location   </p>
  
  <pre><code> KeyStore keyStore = KeyStore.getInstance("PKCS11");
  </code></pre>
  
  <p>with the Error stacktrace:</p>
  
  <pre><code>java.security.KeyStoreException: PKCS11 not found
      at java.security.KeyStore.getInstance(Unknown Source)
      Caused by: java.security.NoSuchAlgorithmException: no such algorithm: PKCS11 for provider SunPKCS11-FooAccelerator
      at sun.security.jca.GetInstance.getService(Unknown Source)
      at sun.security.jca.GetInstance.getInstance(Unknown Source)
      at java.security.Security.getImpl(Unknown Source)
      ... 2 more
  </code></pre>
  
  <p>Help!</p>