Forum Discussion

madhusudana's avatar
madhusudana
Occasional Visitor
7 years ago

tried to read Java key store file using below code . returning null point exception .

getting null point exception when i ran the below code in groovy script

import java.security.Key
import java.security.KeyStore

def keystorePassword ="XXXXXXXX"
def keystoreName = "C:\Users\mmodupalli\Desktop\qeee.jks"
def keystore = KeyStore.getInstance("JKS")
keystore.load(new FileInputStream(keystoreName), keystorePassword.toCharArray())
def key = keystore.getKey("XXXXXX, keystorePassword.toCharArray())
log.info key.getEncoded().encodeBase64()

  • Could post the whole stacktrace of the error, and are you sure this is the correct path?

    -> def keystoreName = "C:\Users\mmodupalli\Desktop\qeee.jks"

     

    This should not compile, since backslashes need to be escaped, like this \\