title: How to set up Java to use user specific certificates for Eclipse?
body: <p>I can't believe I'm the only person to run up against this problem.  I've been googling for hours and have not had any luck. The Java security documentation doesn't seem to address PKCS12 certificates thoroughly.</p>
  
  <p>I am trying to setup Java for user specific PKCS12 certificates.  Among other things, this will be used so that, in Eclipse, I can access a Trac server that is authenticated via certificates.  I am using the Trac Mylyn integration plugin for eclipse.</p>
  
  <p>Here is the setup:</p>
  
  <ul>
  <li>user home directories are at /home</li>
  <li>multiuser mount at /central</li>
  <li>each user has a personal certificate at: ~/user.p12</li>
  <li>password for personal certificates is: pass1234</li>
  <li>the users password is stored in a 0400 file at ~/password.txt</li>
  <li>a read-only trust store for the ca is at: /central/ca.jks</li>
  <li>no password for the truststore</li>
  <li>JDK 1.6 installed at /central/jdk_1.6.0</li>
  <li>Eclipse 3.4 installed at /central/eclipse_3.4.0</li>
  <li>JAVA_HOME=/central/jdk_1.6.0</li>
  <li>JAVA_HOME is set to the JDK location because Eclipse needs this</li>
  <li>ECLIPSE_HOME=/central/eclipse_3.4.0</li>
  <li>JRE lives at $JAVA_HOME/jre</li>
  <li>each user has a ~/.java.policy file</li>
  <li>there is a trac server running at <a href="https://trac.internal/trac" rel="noreferrer">https://trac.internal/trac</a></li>
  <li>the trac server authenticates using certificates</li>
  </ul>
  
  <p>Now, I want to be able to have each user simply modify some file that they own (like the ~/.java.policy file, for example), and be able to launch the central Eclipse application and access the Trac repository.  Seems simple enough.</p>
  
  <p>Right now, the only way I can get this to work is to edit the $ECLIPSE_HOME/eclipse.ini file and add </p>
  
  <pre><code>-Djavax.net.ssl.keyStore="/home/user/user.p12"
  -Djavax.net.ssl.keyStoreType="PKCS12"
  -Djavax.net.ssl.keyStorePassword="pass1234"
  -Djavax.net.ssl.trustStore="/central/ca.jks"
  </code></pre>
  
  <p>Ok, that works, but there are two problems with it:</p>
  
  <ul>
  <li>Each user has to have their own ecipse install. (or can eclipse read that from a user file?)</li>
  <li>It is Eclipse specific, I'd ultimately like to have this as a Java configuration.</li>
  </ul>
  
  <p>Also, I remember from some time back that you can edit the $JAVA_HOME/jre/lib/security/java.security file and add</p>
  
  <pre><code>keystore=/home/user/user.p12
  keystore.type=PKCS12
  keystore.password=pass1234
  truststore=/central/ca.jks
  </code></pre>
  
  <p>But Eclipse doesn't seem to pick that up.  Could it be because my JAVA_HOME points to a JDK, and not the JDK's nested JRE?</p>
  
  <p>I've seen the <a href="http://download.java.net/jdk7/docs/technotes/guides/security/p11guide.html" rel="noreferrer">Java PKCS#11 Reference</a> that references the following properties:
  keyStoreURL="NONE" 
  keyStoreType="PKCS11" 
  keyStorePasswordURL=some_pin_url </p>
  
  <p>There was another reference I saw that said you could edit the ~/.java.policy file to include:</p>
  
  <pre><code>keyStore "file:///home/user/user.p12", "PKCS12", "SunJSSE";
  keyStorePasswordUrl "file:///home/user/password.txt";
  </code></pre>
  
  <p>But that doesn't get picked up either.  Maybe it actually does work and its not getting read for the same reason the java.security file doesn't work, or maybe it just doesn't work at all.</p>
  
  <p>Some system properties I've seen:</p>
  
  <pre><code>javax.net.ssl.keyStore="/home/user/user.p12"
  javax.net.ssl.keyStoreType="PKCS12"
  javax.net.ssl.keyStorePassword="password"
  javax.net.ssl.keyStoreProvider="SunJSSE"
  javax.net.ssl.trustStore="/home/user/ca.jks"
  javax.net.ssl.trustStoreType="JKS"
  javax.net.ssl.trustStorePassword=""
  javax.net.ssl.trustStoreProvider="Sun"
  </code></pre>
  
  <p>So, right now, I guess I'm stuck with having each user to have their own Eclipse intall.  I know it sounds like a complicated setup, but this shouldn't really have anything to do with Eclipse as far as the certificate setup... its really a Java setup for user specific certificates.</p>
  
  <p>Any ideas?</p>