Skip to content

Commit 0c04672

Browse files
committed
handle bad ssl certs differently during link checking
1 parent 2c1577c commit 0c04672

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/qa.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import aiohttp
88

99

10+
TIMEOUT_SEC = 10
11+
12+
1013
class BuildTestFailure(BaseException):
1114
"""Custom exception to indicate a build test failure"""
1215

@@ -77,10 +80,12 @@ async def fetch(session, url, lock):
7780
"""Locked async HTTP GET"""
7881
async with lock:
7982
try:
80-
return await session.get(url, allow_redirects=False, timeout=5)
83+
return await session.get(url, allow_redirects=False, timeout=TIMEOUT_SEC)
84+
except (aiohttp.ClientConnectorSSLError, aiohttp.ClientConnectorCertificateError):
85+
print(f"SSL error when fetching {url}")
86+
return await session.get(url, allow_redirects=False, timeout=TIMEOUT_SEC, ssl=False)
8187
except asyncio.exceptions.TimeoutError:
8288
print(f"Took too long trying to fetch {url}")
83-
return None
8489

8590
async def get_failures(self, links):
8691
"""
@@ -101,6 +106,8 @@ def _test(self):
101106
def strip_fragment_identifiers(link):
102107
return link.split('#')[0]
103108

109+
print()
110+
104111
if self.ignore_internal_links:
105112
links = set(
106113
strip_fragment_identifiers(link) for template_var, link in links.items()

0 commit comments

Comments
 (0)