Skip to content

Commit 7c5dcde

Browse files
committed
Addresses Issue pypa#5572: Implement PIP_TRUSTED_HOSTS logic...
Duplicated logic around line 204 in core.py to allow users to specify index via --index command-line option and validate against PIP_TRUSTED_HOSTS when determining verify_ssl value.
1 parent e8a7b45 commit 7c5dcde

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pipenv/core.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2432,8 +2432,21 @@ def do_install(
24322432
)
24332433
# Add the package to the Pipfile.
24342434
if index_url:
2435+
trusted_hosts = get_trusted_hosts()
2436+
host_and_port = get_host_and_port(index_url)
2437+
require_valid_https = not any(
2438+
(
2439+
v in trusted_hosts
2440+
for v in (
2441+
host_and_port,
2442+
host_and_port.partition(":")[
2443+
0
2444+
], # also check if hostname without port is in trusted_hosts
2445+
)
2446+
)
2447+
)
24352448
index_name = project.add_index_to_pipfile(
2436-
index_url, verify_ssl=index_url.startswith("https:")
2449+
index_url, verify_ssl=require_valid_https
24372450
)
24382451
pkg_requirement.index = index_name
24392452
try:

0 commit comments

Comments
 (0)