I have problems while trying to load pkcs12 file from withCredentials block.
Here is the code I use :

    withCredentials(bindings: [
                                                        
certificate(aliasVariable: 'alias', credentialsId: 'myId', 
keystoreVariable: 'keystoreName', passwordVariable: 'keyPassword')
                                                ]) {
                                                def keystoreFormat = 
"PKCS12"
                                                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
                                                }
                              ....


I always have the following error :

File p12 input stream error : [Pipeline] echojava.io.FileNotFoundException: 
**** (No such file or directory)

I verified the keystoreName file and it exists.

Any help will be appreciate.

-- 
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/afab6cdf-7f41-4269-b629-493501a513b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to