Repository: pytorch
Issue: SSL: CERTIFICATE_VERIFY_FAILED while trying to download pretrained model within a company that transforms SSL certificates for security purposes
Labels: triaged,module: hub

### 🐛 Describe the bug

I currently have difficulty using the code in companies with enhanced security when using external networks.

**from torch.hub import  download_url_to_file
url = 'https://download.openmmlab.com/pretrain/third_party/resnet50_v1c-2cccc1ad.pth'
download_url_to_file(url)**

The following error occurs when I execute the code because the SSL certificate is tampered with by internal security.

  File "C:\Users\user\miniconda3\envs\torch112\lib\site-packages\torch\hub.py", line 727, in load_state_dict_from_url
    download_url_to_file(url, cached_file, hash_prefix, progress=progress)
  File "C:\Users\user\miniconda3\envs\torch112\lib\site-packages\torch\hub.py", line 593, in download_url_to_file
    u = urlopen(req)
  File "C:\Users\user\miniconda3\envs\torch112\lib\urllib\request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\user\miniconda3\envs\torch112\lib\urllib\request.py", line 519, in open
    response = self._open(req, data)
  File "C:\Users\user\miniconda3\envs\torch112\lib\urllib\request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "C:\Users\user\miniconda3\envs\torch112\lib\urllib\request.py", line 496, in _call_chain
    result = func(*args)
  File "C:\Users\user\miniconda3\envs\torch112\lib\urllib\request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "C:\Users\user\miniconda3\envs\torch112\lib\urllib\request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: CA certificate key too weak (_ssl.c:997)>

It seems that there was a similar issue as follows #33288
And there is a case of solving the cause in the issue.

**import ssl
ssl._create_default_https_context = ssl._create_unverified_context**

Can I request PR for the code to which this solution is applied?

### Versions

PyTorch version: 1.12.1
Is debug build: False
CUDA used to build PyTorch: 11.6
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 10 Enterprise
GCC version: Could not collect
Clang version: Could not collect
CMake version: Could not collect
Libc version: N/A

Python version: 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:29:51) [MSC v.1929 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.19042-SP0
Is CUDA available: True
CUDA runtime version: 11.6.55
CUDA_MODULE_LOADING set to:
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3090
Nvidia driver version: 516.94
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.23.3
[pip3] torch==1.12.1
[pip3] torchaudio==0.12.1
[pip3] torchvision==0.13.1
[conda] blas                      2.116                       mkl    conda-forge
[conda] blas-devel                3.9.0              16_win64_mkl    conda-forge
[conda] cudatoolkit               11.6.0              hc0ea762_10    conda-forge
[conda] libblas                   3.9.0              16_win64_mkl    conda-forge
[conda] libcblas                  3.9.0              16_win64_mkl    conda-forge
[conda] liblapack                 3.9.0              16_win64_mkl    conda-forge
[conda] liblapacke                3.9.0              16_win64_mkl    conda-forge
[conda] mkl                       2022.1.0           h6a75c08_874    conda-forge
[conda] mkl-devel                 2022.1.0           h57928b3_875    conda-forge
[conda] mkl-include               2022.1.0           h6a75c08_874    conda-forge
[conda] numpy                     1.23.3          py310h4a8f9c9_0    conda-forge
[conda] pytorch                   1.12.1          py3.10_cuda11.6_cudnn8_0    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torchaudio                0.12.1              py310_cu116    pytorch
[conda] torchvision               0.13.1              py310_cu116    pytorch

cc @nairbv @NicolasHug @vmoens @jdsgomes