Certificates

Q.1 The default truststore is stored in jre/lib/security/cacertsWe can set the path by System.setProperty ("javax.net.ssl.trustStore", "c:\\cacerts");How can i get the default path of truststore?Q. 2 How can i get trusted certificate from the system?
[300 byte] By [georgefungkp] at [2007-9-26 4:16:18]
# 1

1. There is nothing called default path of truststore Hwever there is something called default truststore See (and your question seems to suggest that you have seen it) http://java.sun.com/products/jsse/doc/guide/API_users_guide.html#CustomizingStores

2. An example(again, based on sample code from JSSE 1.0.2) of getting a certificate from a truststore that works for me is...

import java.io.*;

import java.security.*;

public class DisplayCertificate

{

public static void main(String[] args) throws Exception

{

KeyStore theTrustStore = KeyStore.getInstance("JKS");

theTrustStore.load(new FileInputStream(args[0]), args[1].toCharArray());

java.security.cert.Certificate theCertificate = theTrustStore.getCertificate(args[2]);

System.out.println("The certificate for alias " + args[2] + " is " + theCertificate);

}

};

And when I run it like...

java DisplayCertificate G:\jsse1.0.2\samples\samplecacerts changeit duke

i get this output...

The certificate for alias duke is [

[

Version: V1

Subject: CN=duke, OU=Java Software, O="Sun Microsystems, Inc", L=Cupertino, ST=California, C=US

Signature Algorithm: MD5withRSA, OID = 1.2.840.113549.1.1.4

Key: com.sun.rsajca.JSA_RSAPublicKey@6e1408

Validity: [From: Wed Mar 29 19:16:53 EST 2000,

To: Sun Sep 15 20:16:53 EDT 2002]

Issuer: CN=duke, OU=Java Software, O="Sun Microsystems, Inc", L=Cupertino, ST=California, C=US

SerialNumber: [38e29cf5 ]

]

Algorithm: [MD5withRSA]

Signature:

0000: 83 CE C6 F8 E2 73 11 B2A0 A8 1A F4 07 BC 5B 82 .....s........[.

0010: 71 0E 7F 23 E7 69 88 D4BC 59 19 D5 FD CF 0D 8B q..#.i...Y......

0020: 2E 1E 88 A4 34 92 F9 699F AA A7 98 15 1A B0 AC ....4..i........

0030: 9B C2 79 17 51 F9 C0 D79C 69 96 FD D0 71 45 7C ..y.Q....i...qE.

0040: 74 FD CD FF AD 42 58 820D FA E8 61 28 CB AE AF t....BX....a(...

0050: AE 0E F1 63 6C 52 10 C3D4 62 20 28 36 89 F0 43 ...clR...b (6..C

0060: 47 26 C0 98 50 50 55 A877 69 0F 72 F6 C7 26 79 G&..PPU.wi.r..&y

0070: B9 EE 13 AF 0E 59 5C CEC7 23 CF 02 14 22 99 42 .....Y\..#...".B

]

neville_sequeira at 2007-6-29 13:25:44 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 2

Have you ever managed to run the exact same code as above, except loading the truststore from a JAR file rather than the file system?

I find that I get an "SSL Implementation not available" exception at connect time when I load the store from a JAR. Altho everything works fine when I use the code above to just load it as a file from the file system.

Showstopper mode here. Anyone any clues?

fergalnyc at 2007-6-29 13:25:44 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...