Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help! How to put a keystore file inside a jar?

843811Mar 23 2005 — edited Aug 27 2007
Before i build the jar file, my keystore file "key1" which generated by keytool is in the same directory of my main class.

there is also another txt file called "Extras", where there is one entry in there:
javax.net.ssl.trustStore=key1

before the program does anything, i put:
try{
InputStream propFile = ClassLoader.getSystermResourceAsStream("Extras");
Properties p = new Properties(System.getProperties());
p.load(propFile);

// set the system properties
System.setProperties(p);

// display new properties
//System.getProperties().list(System.out);
} catch (Exception e){......}

i can run the app only with: java MainClass instead of java -Djavax.ssl.trustStore=key1 MainClass

but after i build the whole thing in a jar file, it seems not be able to access to "key1" the keystore file.

it only works when i put the key1 file in the same directory of the jar file.

anyone knows how would i solve this problem? i just want only one jar file, i dont want to ask the user to download a key file, which doesnt look SECURE at all to them.

Thank you very much.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 24 2007
Added on Mar 23 2005
9 comments
3,268 views