Skip to content

Commit 2d1b943

Browse files
ntouranAA-Turner
andauthored
Apply tls_verify and tls_cacerts to ImageDownloader (#11716)
Co-authored-by: Adam Turner <[email protected]>
1 parent db9e476 commit 2d1b943

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ Bugs fixed
5050
* #11675: Fix rendering of progression bars in environments that do not support
5151
ANSI control sequences.
5252
Patch by Bénédikt Tran.
53+
* #11715: Apply ``tls_verify`` and ``tls_cacerts`` config to
54+
``ImageDownloader``.
55+
Patch by Nick Touran.
5356

5457
Testing
5558
-------

sphinx/transforms/post_transforms/images.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ def handle(self, node: nodes.image) -> None:
7575
timestamp: float = ceil(os.stat(path).st_mtime)
7676
headers['If-Modified-Since'] = epoch_to_rfc1123(timestamp)
7777

78-
r = requests.get(node['uri'], headers=headers)
78+
config = self.app.config
79+
r = requests.get(
80+
node['uri'], headers=headers,
81+
_user_agent=config.user_agent,
82+
_tls_info=(config.tls_verify, config.tls_cacerts),
83+
)
7984
if r.status_code >= 400:
8085
logger.warning(__('Could not fetch remote image: %s [%d]') %
8186
(node['uri'], r.status_code))

0 commit comments

Comments
 (0)