How to pass a custom certificate to Jenkins class?
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
This is not currently supported by jenkinsapi, but we're welcome pull request (with tests) for this.
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))
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.
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.
- False
- True
- 'some_cert.pem' - I've used it together with the package "wincertstore", so I write:
ssl_verify=certfile.nameits the same as with the option "verify" in the requests package Can someone confirm this?
The ssl_verify is passed to requests as is, so if that works for requests, it shall work for jenkinsapi as well.
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).
@tuukkamustonen Please submit pull request for this documentation. :)