jenkinsapi icon indicating copy to clipboard operation
jenkinsapi copied to clipboard

How to pass a custom certificate to Jenkins class?

Open erkinun opened this issue 10 years ago • 7 comments

Hi,

I am using the jenkinsapi library in my company's development environment where we have a custom signed certificate. There may be cases where I have to explicitly use this certificate with jenkinsapi(otherwise I will get the certificate error which ssl_verify flag is being used to pass in development stages). Is there a way to achieve this functionality with the current API?

I mean, is there a way to do something similar:

J = jenkins.Jenkins(host, user, pass, cert='some_cert.pem')

I've looked through the code but I couldn't find a such way.

Thanks, Erkin

erkinun avatar Jan 22 '16 13:01 erkinun

This is not currently supported by jenkinsapi, but we're welcome pull request (with tests) for this.

lechat avatar Jan 22 '16 13:01 lechat

I've forked the repo and added the necessary optional parameters, but ant test doesn't seem to work, is that really the case or am I doing something wrong? (todo also says that * Add a testsuite (preferably nose or py.test) which doesn't rely on a local jenkins setup (or instantiates one during test))

erkinun avatar Jan 26 '16 11:01 erkinun

Ant? We don't use ant.

You need to add a test module (or add new test to existing module) in jenkinsapi_tests. Subfolder systests is for tests that use real Jenkins instance and unittests is for tests that mock Jenkins.

Look in https://github.com/salimfadhley/jenkinsapi/blob/master/.travis.yml on how tests are executed.

lechat avatar Jan 26 '16 12:01 lechat

I also looking for accessing Jenkins with a CA Certificate. So I deal with the code and I find out that there are 3 possibilities for the "ssl_verify"-option.

  1. False
  2. True
  3. 'some_cert.pem' - I've used it together with the package "wincertstore", so I write: ssl_verify=certfile.name its the same as with the option "verify" in the requests package Can someone confirm this?

obelix05 avatar Jan 09 '17 10:01 obelix05

The ssl_verify is passed to requests as is, so if that works for requests, it shall work for jenkinsapi as well.

lechat avatar Jan 09 '17 13:01 lechat

I confirm that you can pass path to a cert file in ssl_verify as in:

Jenkins('https://jenkins.local', ssl_verify='/path/to/local/cert.pem')

Or you can point to the file with REQUESTS_CA_BUNDLE env variable (requests will obey it).

You can't refer to multiple cert files, but need to combine the whole certificate chain to a single PEM file.

I think this ticket could be closed (although, documentation could be added).

mtvx avatar May 10 '17 10:05 mtvx

@tuukkamustonen Please submit pull request for this documentation. :)

lechat avatar Jul 03 '17 15:07 lechat