# How to update requests.Session with proxies and verify parameter to be used by all huggingface libraries (proxy with TLS interception)

**URL:** <https://discuss.huggingface.co/t/how-to-update-requests-session-with-proxies-and-verify-parameter-to-be-used-by-all-huggingface-libraries-proxy-with-tls-interception/51087>\
**Category:** 🤗Hub\
**Created:** [August 17, 2023, 9:48am UTC](https://discuss.huggingface.co/t/how-to-update-requests-session-with-proxies-and-verify-parameter-to-be-used-by-all-huggingface-libraries-proxy-with-tls-interception/51087 "2023-08-17T09:48:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ftarrade](https://avatars.discourse-cdn.com/v4/letter/f/8c91f0/32.png) [@ftarrade](https://discuss.huggingface.co/u/ftarrade)\
**Post date:** [August 17, 2023, 9:48am UTC](https://discuss.huggingface.co/t/how-to-update-requests-session-with-proxies-and-verify-parameter-to-be-used-by-all-huggingface-libraries-proxy-with-tls-interception/51087/1 "2023-08-17T09:48:30Z")

</div>

Hi there,

I need to overwrite the requests.session to be able to use HuggingFace (models, datasets) in a company setup with proxy and TLS interception. As this is not working with CA certificate I need to deactivate it.

It seems that [https://github.com/huggingface/huggingface\_hub/blob/main/src/huggingface\_hub/hf\_api.py](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/hf_api.py) is used in all cases like when downloading a dataset.

Following the documentation I tried the following

```auto
def backend_factory() -> requests.Session:
    session = requests.Session()
    session.proxies = {"http": "proxy_server:port", "https": "proxy_server:port"}
    session.verify = False
    return session

configure_http_backend(backend_factory=backend_factory)

session = get_session()

```

I can see when using the get\_session that session.proxies and verify are set properly but this doesn’t work.

I am using the following key libraries:

```auto
python 3.10.12
huggingface_hub 0.16.4
datasets 2.13.0
transformers 4.30.2
requests 2.31.0

```

Is there something wrong in the way I am trying to overwrite the session parameters ? I am not sure if the full requests.session is passed (should work then) or if only requests.session.proxies is used (seems the latest when quickly looking at the code hf\_api.py)

Any suggestion on how to get this working ?

Thanks

---

<div class="post-metadata">

**Author:** ![ftarrade](https://avatars.discourse-cdn.com/v4/letter/f/8c91f0/32.png) [@ftarrade](https://discuss.huggingface.co/u/ftarrade)\
**Post date:** [August 29, 2023, 12:17pm UTC](https://discuss.huggingface.co/t/how-to-update-requests-session-with-proxies-and-verify-parameter-to-be-used-by-all-huggingface-libraries-proxy-with-tls-interception/51087/2 "2023-08-29T12:17:22Z")

</div>

After some investigation it seems that there few issues with HuggingFace library to work with a proxy server with TLS and CA certificates. This impact transformers and datasets libraries. I will open a bug report.

---

<div class="post-metadata">

**Author:** ![DancePartner](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/dancepartner/32/25857_2.png) [@DancePartner](https://discuss.huggingface.co/u/DancePartner)\
**Post date:** [April 15, 2024, 7:28pm UTC](https://discuss.huggingface.co/t/how-to-update-requests-session-with-proxies-and-verify-parameter-to-be-used-by-all-huggingface-libraries-proxy-with-tls-interception/51087/3 "2024-04-15T19:28:26Z")

</div>

Any updates on this? similar working environment issue  
$ git config --local http.sslVerify false  
before fetching

---

<div class="post-metadata">

**Author:** ![yhlim](https://avatars.discourse-cdn.com/v4/letter/y/90db22/32.png) [@yhlim](https://discuss.huggingface.co/u/yhlim)\
**Post date:** [June 22, 2024, 4:55pm UTC](https://discuss.huggingface.co/t/how-to-update-requests-session-with-proxies-and-verify-parameter-to-be-used-by-all-huggingface-libraries-proxy-with-tls-interception/51087/4 "2024-06-22T16:55:35Z")

</div>

Is there any updates on this? dataset streaming is the last thing I need to get my training started
