Forum Discussion

prachik's avatar
prachik
New Contributor
7 years ago

Accessing Jks(Java Keystore) file in Script

Hi All,

I want to retrieve the private key stored in Jks file using the java KeyStore class in script snap.

I have uploaded the Jks file in the files section of my project. Now, using the FileInputStream I try to load the jks file in Script snap, but I always get the error that “No such file or directory found”. I have tried various permutations for the file path but in vain. Could someone help me and suggest what should be the file path. Or is there any other way to read the Jks file.

Below is my python script code :

keystore=java.security.KeyStore.getInstance("JKS")
keyPassword="123456"
charArray=list(keyPassword)
stream =java.io.FileInputStream("sldb:\\\MyFile.jks");
keystore.load(stream,charArray)

2 Replies

  • David_Wang's avatar
    David_Wang
    New Contributor II

    Hi,

    Have you tried to specified project name in the path? I though if we using sldb protocol, looks like we will need using relative path. try to upload the jks into root of shared project and try first one.

    Example:
    sldb:///shared/MyFile.jks
    sldb:///project-name/MyFile.jks

  • Hi, have you tried reading it from the plex hard disk? i.e c:\temp\MyFile.jks or /tmp/MyFile.jks if Linux.