title: Implementing Digital Signing in a Java Applet
body: <p>I am trying to sign some data (a POST form) in a web based application using a Java Applet. The user's x509 certificate would be in a cryptoken/smart card. The signature needs to be in attached pkcs#7 format.</p>
  
  <p>I am using this tutorial/code as a starting point in building the applet - <a href="http://www.developer.com/java/other/article.php/3587361/Java-Applet-for-Signing-with-a-Smart-Card.htm" rel="nofollow">http://www.developer.com/java/other/article.php/3587361/Java-Applet-for-Signing-with-a-Smart-Card.htm</a></p>
  
  <p>The biggest problem for me here seems to be the fact that the applet asks the user for location of the pkcs#11 implementation library. This is a big no-no for me because my typical user is not going to know the location of his pkcs#11 library.</p>
  
  <p>From Oracle's Java documentation - <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/security/p11guide.html" rel="nofollow">http://docs.oracle.com/javase/6/docs/technotes/guides/security/p11guide.html</a> it seems that Java doesn't come with it's own implementation.</p>
  
  <p>Is there a way to do this signing without asking the user for this location. I am OK with a solution which only works with just IE and Firefox on Windows.</p>
  
  <p>With a few smartcards/cryptokens I have used, I have noticed that the moment I insert it, I can see the certificate in IE &amp; Firefox's personal tab of certificates. This probably means that the crypto token registers all the certificates it contains with OS when you insert the card and deregisters it when you remove it. So it must probably be exposing some interface to the OS/Browser when it does it - can this not be used for signing?</p>