Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import requests gives SSL error in datadog client #873

Closed
leetemil opened this issue Mar 9, 2022 · 3 comments
Closed

import requests gives SSL error in datadog client #873

leetemil opened this issue Mar 9, 2022 · 3 comments
Labels

Comments

@leetemil
Copy link

leetemil commented Mar 9, 2022

Describe the bug
If the line import requests is added to the code example for service checks, I get an SSL error from the datadog api client.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://docs.datadoghq.com/api/latest/service-checks/
  2. Run the python code example and see that it indeed works with response {'status': 'ok'}
  3. Add import requests to that code example.
  4. See error, with traceback ending with something as follows
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.datadoghq.eu', port=443): Max retries exceeded with url: /api/v1/check_run (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

Expected behavior
The import of requests should cause no change in behavior.

Environment and Versions (please complete the following information):
linux

  • version for this project in use.

  • 1.10.0

  • services, libraries, languages and tools list and versions.
    requests==2.22.0
    pyOpenSSL==22.0.0
    datadog_api_client==1.10.0
    python 3.8.12

@therve
Copy link
Contributor

therve commented Mar 9, 2022

Hi,

It looks more an issue with pyOpenSSL than requests. Can you upgrade requests to at least 2.24.0? It seems to work starting that version.

@leetemil
Copy link
Author

leetemil commented Mar 9, 2022

It works by upgrading. I also made it work with the workaround in #812 for those with older versions of requests. Thanks for taking a look @therve

@leetemil leetemil closed this as completed Mar 9, 2022
@therve
Copy link
Contributor

therve commented Mar 9, 2022

No problem! For the record, the issue comes from the inject_into_urllib3 call which was removed in psf/requests#5443 (and is not recommended).

But if you're stuck with that version of requests (or want to use pyOpenSSL for some reasons), you can fix it by pass the CA certs directly, eg:

from datadog_api_client.v1 import Configuration
import certifi

configuration = Configuration(ssl_ca_cert=certifi.where())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants