Jenkins credentials - how to use .P12 certificate

I have a problem with certificates, and I'm not even sure if I chose the right path ... In short. I need my jenkins job to download something during build from a website where I need to use certificate authentication. I have .p12 and .cert certificates. I thought I was just importing them through the Credentials plugin in Jenkins, and so I can use them in tasks, but I cannot do this.

What I have done so far: I created keystore xxx.jks and imported p12 and cert into it. I tried to add to it the path to "From the PKCS # 12 file on the main Jenkins", but get the message: Could not load keystore java.io.IOException: DerInputStream.getLength(): lengthTag=109, too big.

I tried to download a certificate from Jenkins, but got the following: Could retrieve key "cert alias". You may need to provide a password java.security.UnrecoverableKeyException: Get Key failed: null

I would appreciate any advice or suggestions, including useful documentation (I tried, but I can not find anything useful for me honestly).

Many thanks.

+4
source share
2 answers

There are several ways:

  • You can import the certificate somewhere on a Jenkins machine and reference this absolute location with the command wget.
  • You can put the certificate in SVN so that it becomes part of the verification of the workspace, use the relative location with the command wget.
  • You can use File Parameterto configure the task, which prompts you to upload the file to the workspace of the task, however you need to provide it so that every time the task is executed.
  • Plain Credentials Plugin, " Zip ", Build Secret Plugin ( , , )
0

https://wiki.jenkins.io/display/JENKINS/Credentials+Binding+Plugin

Jenkins . - :

stage('Get orders JSON from web service') {
    withCredentials([file(credentialsId: 'certID', variable: 'MY_CERT')]) {
        ORDERS_JSON = sh(
           script: "curl --cert $MY_CERT https://host.com/api/orders -k",
           returnStdout: true
        ).trim()
    }
}
0

Source: https://habr.com/ru/post/1538558/


All Articles