Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use configured CA certificate when downloading packages #3349

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion poetry/installation/chooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,18 @@ def choose_for(self, package): # type: (Package) -> Link

return chosen

def _get_links(self, package): # type: (Package) -> List[Link]
def _get_repository(self, package):
if not package.source_type:
if not self._pool.has_repository("pypi"):
repository = self._pool.repositories[0]
else:
repository = self._pool.repository("pypi")
else:
repository = self._pool.repository(package.source_reference)
return repository

def _get_links(self, package): # type: (Package) -> List[Link]
repository = self._get_repository(package)

links = repository.find_links_for_package(package)
Copy link
Contributor Author

@intgr intgr Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the most appropriate way to pass along the repository attribute to Executor._download_link? Should I add a repository attribute to the Link class? 🤔


Expand Down
11 changes: 8 additions & 3 deletions poetry/installation/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,10 @@ def _download_link(self, operation, link):

archive = self._chef.get_cached_archive_for_link(link)
if archive is link:
repository = self._chooser._get_repository(operation.package)
# No cached distributions was found, so we download and prepare it
try:
archive = self._download_archive(operation, link)
archive = self._download_archive(operation, link, repository)
except BaseException:
cache_directory = self._chef.get_cache_directory_for_link(link)
cached_file = cache_directory.joinpath(link.filename)
Expand All @@ -611,9 +612,13 @@ def _download_link(self, operation, link):

return archive

def _download_archive(self, operation, link): # type: (Operation, Link) -> Path
def _download_archive(self, operation, link, repository): # type: (Operation, Link, LegacyRepository) -> Path
response = self._authenticator.request(
"get", link.url, stream=True, io=self._sections.get(id(operation), self._io)
"get",
link.url,
stream=True,
io=self._sections.get(id(operation), self._io),
verify=getattr(repository, 'cert'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only LegacyRepository has the cert attribute, should I have an isinstance() check or is getattr() good enough?

)
wheel_size = response.headers.get("content-length")
operation_message = self.get_operation_message(operation)
Expand Down