Sunday 7 May 2017

Creating Certificate store using java.

Using java you can create any type of certificate store. In the below example, I have created a JKS certificate store using sun.security.tools.KeyTool  API.

import java.io.*;
import java.io.FileInputStream;
import java.security.KeyStore;
import sun.security.tools.KeyTool;

public class CreateCert {
    public static void main(String[] args) throws Exception {
        String FILE= [JKS FILE LOCATION];
        new File(FILE).delete();
        KeyTool.main(("-debug -genkeypair -keystore " + FILE + " -alias a -dname cn=[YOUR_NAME] -storepass [PASSWORD]"+ " -keypass changeit -keyalg rsa").split(" "));
        System.out.println("done");
        KeyStore ks=KeyStore.getInstance("JKS");
        System.out.println(ks.getType());
    }
}



Change the following parameter with your own values

[JKS FILE LOCATION] = path of the jks file  ex. "C://Test.jks"
[YOUR_NAME] = Your full name as JKS cn.
[PASSWORD] = Password of your JKS file.

Run the code. Your JKS will be created in the specified location.

No comments:

Post a Comment

Followers

OIM API for adding process task and retry failed task

 In this blog you can find how to add new process task and retry any failed/rejected tasks using API. Adding new process task: /************...