cancel
Showing results for 
Search instead for 
Did you mean: 

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

Highlighted
Occasional Visitor

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()

1 REPLY 1
Contributor

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

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 \\