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

ERROR - Cannot set verify_mode to CERT_NONE when check_hostname is enabled #6719

Closed
Barsovski opened this issue May 23, 2024 · 1 comment
Closed

Comments

@Barsovski
Copy link

Barsovski commented May 23, 2024

I'm working with the exchangelib (v5.4) library.
A couple of days ago I noticed that in the Docker container exchangelib started complaining with an error ValueError: Cannot set verify_mode to CERT_NONE when check_hostname is enabled.

Exchangelib tries to connect to a local server with a low security level via a custom adapter with this lines

from requests.adapters import HTTPAdapter


class CustomHttpAdapter(HTTPAdapter):
    """Transport adapter that allows us to use custom ssl_context."""

    def __init__(self, ssl_context=None, **kwargs):
        self.ssl_context = ssl_context
        super().__init__(**kwargs)

    def init_poolmanager(self, connections, maxsize, block=False, **kwargs):
        self.ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
        self.ssl_context.set_ciphers('DEFAULT:@SECLEVEL=0')
        self.ssl_context.check_hostname = False

        self.poolmanager = urllib3.poolmanager.PoolManager(
            num_pools=connections, maxsize=maxsize,
            block=block, ssl_context=self.ssl_context, ssl_version=ssl.PROTOCOL_TLSv1)

With this exchangelib shows an error:

File "/usr/local/lib/python3.11/site-packages/cached_property.py", line 70, in __get__
2024-05-23T11:53:23.558367392Z     return obj_dict[name]
2024-05-23T11:53:23.558368832Z            ~~~~~~~~^^^^^^
2024-05-23T11:53:23.558370213Z KeyError: \'calendar\'

But if I change the version of requests package from 2.32.0 to 2.31.0, connection and information exchange occurs normally.

System Information

{
  "chardet": {
    "version": null
  },
  "charset_normalizer": {
    "version": "3.3.2"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "3.7"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.11.9"
  },
  "platform": {
    "release": "6.5.0-35-generic",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.32.0"
  },
  "system_ssl": {
    "version": "300000b0"
  },
  "urllib3": {
    "version": "2.2.1"
  },
  "using_charset_normalizer": true,
  "using_pyopenssl": false
}
@sigmavirus24
Copy link
Contributor

In the future, please search closed and open issues before creating new ones that are duplicates.

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

No branches or pull requests

2 participants