devopshq / teamcity

dohq-teamcity is a Python package providing access to the JetBrains TeamCity server API.
https://devopshq.github.io/teamcity/
MIT License
33 stars 12 forks source link

Need to set SSL Verification on TeamCity calls #46

Closed richard-nilsson closed 1 year ago

richard-nilsson commented 1 year ago

Hello,

At my current assignment, we have left basic authentication, and only use Token based identification. After quite some searching on the web, I found how to configure this: ... tc_token = <get token> config = Configuration() config.api_key = {'mytoken': tc_token} config.api_key_prefix = {'mytoken': 'Bearer'} config.active_api_key = 'mytoken' tc = TeamCity(url, auth_settings=["Token"], configuration=config) ... However, I get SSL error. After more searching on the WEB, I solved the problem when using SSL Verification for the requests.get() call: cacert_file = "/etc/pki/tls/certs/cacert.pem" response = requests.get(url, headers=headers, verify=cacert_file)

Is there a way to configure the TeamCity() call in dohq to use SSL verification in the same way as it is possible for a requests.get() call?

Regards, Richard

allburov commented 1 year ago

Have a look at these parameters https://github.com/devopshq/teamcity/blob/develop/dohq_teamcity/configuration.py#L82-L91

        # SSL/TLS verification
        # Set this to false to skip verifying SSL certificate when calling API
        # from https server.
        self.verify_ssl = True
        # Set this to customize the certificate file to verify the peer.
        self.ssl_ca_cert = None
        # client certificate file
        self.cert_file = None
        # client key file
        self.key_file = None
richard-nilsson commented 1 year ago

YES! That did the trick: config.ssl_ca_cert = '/etc/pki/tls/certs/cacert.pem' And voila! No SSL errors! Many thanks.