Skip to content

Commit

Permalink
Make use of tls_validation when syncing signatures
Browse files Browse the repository at this point in the history
closes #1305
  • Loading branch information
lubosmj committed Jul 28, 2023
1 parent 1253b5c commit 2779865
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES/1305.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disabled TLS validation, if opted out in a remote, when syncing signatures.
7 changes: 7 additions & 0 deletions pulp_container/app/downloaders.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import aiohttp
import asyncio
import json
import ssl
import re

from aiohttp.client_exceptions import ClientResponseError
Expand Down Expand Up @@ -204,6 +205,12 @@ def _make_aiohttp_session_from_remote(self):
"""
tcp_conn_opts = {"force_close": True}

if not self._remote.tls_validation:
sslcontext = ssl.create_default_context()
sslcontext.check_hostname = False
sslcontext.verify_mode = ssl.CERT_NONE
tcp_conn_opts["ssl_context"] = sslcontext

headers = MultiDict({"User-Agent": NoAuthDownloaderFactory.user_agent()})
if self._remote.headers is not None:
for header_dict in self._remote.headers:
Expand Down
5 changes: 2 additions & 3 deletions pulp_container/app/tasks/sync_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,13 @@ async def get_signature_source(self):
return SIGNATURE_SOURCE.SIGSTORE

registry_v2_url = urljoin(self.remote.url, "v2/")
extension_check_downloader = self.remote.get_noauth_downloader(url=registry_v2_url)
extension_check_downloader = self.remote.get_downloader(url=registry_v2_url)
response_headers = {}
try:
result = await extension_check_downloader.run()
response_headers = result.headers
except aiohttp.client_exceptions.ClientResponseError as exc:
if exc.status == 401:
response_headers = dict(exc.headers)
pass
if response_headers.get(SIGNATURE_HEADER) == "1":
return SIGNATURE_SOURCE.API_EXTENSION

Expand Down

0 comments on commit 2779865

Please sign in to comment.