sketchub icon

Keystore Reader

HR-Projects
8 Likes
0 Comments
92 Downloads

Screenshots

About

When I run this project using Terminal Emulator there were no errors but when it was implemented in an Android application I saw some such issues.

'java.security.KeyStoreException: JKS not found'

import java.io.FileInputStream; import java.security.KeyStore; import java.security.cert.Certificate;

public class ReadJKSFile {

public static void main(String[] args) {
    String keystoreFile = "/storage/emulated/0/NP/jks/tast.jks";
    String keystorePassword = "tast";
    String alias = "tast";

    try {
        // Load the Keystore
        KeyStore keyStore = KeyStore.getInstance("JKS");
        FileInputStream inputStream = new FileInputStream(keystoreFile);
        keyStore.load(inputStream, keystorePassword.toCharArray());

        // Retrieve the certificate using the alias
        Certificate certificate = keyStore.getCertificate(alias);

        if (certificate != null) {
            System.out.println("Certificate found:");
            System.out.println(certificate.toString());
        } else {
            System.out.println("Certificate with alias " + alias + " not found.");
        }

        inputStream.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

}

©2024 Sketchub | User Policy