I am trying to retrieve keystore from a PKCS12 file stored as credential.
Here is the code I use :

 
                                       withCredentials(bindings: [
                                                        certificate(
aliasVariable: 'alias', credentialsId: 'myId', keystoreVariable: 
'keystoreName', passwordVariable: 'keyPassword')
                                                ]) {
                                                def keystoreFormat = 
"PKCS12"
                                                print "test : " + Secret(
                                                try {

                                                        try {
                                                                p12file = 
new FileInputStream(keystoreName)
                                                        } catch (error) {
                                                                println "File 
p12 input stream error :"
                                                                println 
error.toString()
                                                                println 
error.getMessage()
                                                                 print error
.printStackTrace()
                                                                throw error
                                                        }
                                                        
                                                        println "P12file 
opened"

                                                        try {
                                                                keystore = 
KeyStore.getInstance(keystoreFormat)
                                                                keystore.
load(p12file, keyPassword.toCharArray())
                                                        } catch (error) {
                                                                println 
"Loading 
KeyStore :"
                                                                println 
error.toString()
                                                                println 
error.getMessage()
                                                                print error.
printStackTrace()
                                                                throw error
                                                        }
                                                        def key = keystore.
getKey(alias, keyPassword.toCharArray())

                                                        println "-----BEGIN 
PRIVATE KEY-----"
                                                        println key.
getEncoded().encodeBase64()
                                                        println "-----END 
PRIVATE KEY-----"
                                                } catch(error) {
                                                        print "Error 
Reading p12 : "
                                                        println error.
toString()
                                                        println error.
getMessage()
                                                        print error.
printStackTrace()
                                                        throw error
                                                }




This code always result in 
File p12 input stream error :

[Pipeline] echojava.io.FileNotFoundException: **** (No such file or 
directory)[Pipeline] echo**** (No such file or directory)

I could verify that the file exists, but I can't open it.

Any idea will be greatly appreciate.
Many thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/debf2eb3-2c7f-457c-9129-db1d1235e4ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to