File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Create keystore and truststore programatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Create keystore and truststore programatically" Watch "Create keystore and truststore programatically" New topic
Author

Create keystore and truststore programatically

Marcelo Tataje
Ranch Hand

Joined: Jan 31, 2011
Posts: 64

Hello everybody, I want to make a Java App to manage certificates.

For example, for a keystore, in the requirements I've received, I need two files that I've already have:
1. Certificate (.cer or .pem extension),
2. the private key file (.key extension).
I wonder to know how can I create my own keystore with these files, how do I set the alias, password and all what my keystore needs.

Now, what I've also been asked for is to create a truststore based on the keystore:
- Generate a .CER file from keystore.jks
- Import .cer file into a new file named truststore.jks
- Import Root certificate (which I already have)
- Import Intermediate certificate (which I already have)


And I know that all what I want is possible with the "keytool" java offers, but I need an application that can do all this process. I've been thinking on using the Runtime class to execute keytool commands, but for some of the commands I need a confirmation and I couldn't manage to find how to accept or decline a command executed from java.

Is there maybe a framework for this kind of job. I'd really appreciate your help and thanks in advanced.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

How about KeyStore? (<= click on it)


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Create keystore and truststore programatically
 
Similar Threads
Applets, SSL Sockets, and Certificates
problem calling a remote webservice [ Algo Error]
Import p12 (certificate) to smart card. Keystore, pkcs11, etc.
CXF keystore question
Doubt about digital certificates and signatures