-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Allow root CA bundle to be configured #1012
Comments
Hi, |
can you confirm/deny whether
Arguably that's just a documentation problem. While encapsulation can be good, The bigger question, I think, is whether/how-much to expose Pip directly through Poetry. i.e. In pytest there is the env var, this under-the-hood-config question is kinda relevant to #558 (though there it is about pip maybe this relates to what #697 is getting at too... just generally how much to connect Poetry's high-level view to the lower-level nuts and bolts of the tools involved. vs. how much to have known-good ways to "break out" of the typical paths to customize for your needs... while remaining compatible with Poetry |
Yes, using REQUESTS_CA_BUNDLE works. I don’t think it’s a documentation issue though. Having to set an environment variable while there is the “poetry config” command is counter intuitive. |
Maybe adding Rather than include requests config in poetry configuration, having a script to set env vars in the project sounds better. |
From a UX point of view this isn't true. People use poetry. They shouldn't care about what's underneath. A lot of tools use this approach (configuration options for the tool, not it's libraries) |
@jobec You are probably right. It should be handled by poetry. What I considered about is the inconsistency between the env vars and the poetry CA config. Placing it in env vars is fine. And we can choose handling it by python or the shell. Temporary or not. |
I just ran into this issue and the solution of setting REQUESTS_CA_BUNDLE will be extremely inconvenient. We are currently using two private repositories: an internal one with a corporate certificate and a SaaS hosted one with a public certificate. If I set the REQUESTS_CA_BUNDLE to the corporate certificate, the SaaS won't work and if I set it to the regular bundle, the private one won't work. A workaround would be to create a hybrid bundle with both in it and I could manage this on the builds but this would also require that all users set the variable to the hybrid bundle when working on the repo. Having a "cert = " field in source would solve this problem on a per source basis. |
@kmray Is the project public to outer space? There is no need to add field if hybrid bundle is usable to all project members. |
I'm forgetting if GitHub emails people on cross ticket mentions but I have a PR, #1325, that addresses this request. The developers said in Discord that they're ranking PRs by number of votes so please +1 the PR :) |
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
🤔 With #1325, can we use Poetry to set the CA Certificate path rather than the hackish REQUESTS_CA_BUNDLE variable? I've tried to read through the documentation/tickets and tried a number of options, but still run into the self-signed certificate error (I'm on Windows in a corporate environment that uses a self-signed certificate) |
Is this for installing packages? If so, [[tool.poetry.source]]
name = "foo"
url = "https://foo.bar/simple/" There is still an outstanding bug if you have periods in your repo shortname. |
Is there a user error on my part or is the feature not intended for this use case? This works:
But I'm running errors when trying:
(Note: also tried adding I added the below snippet to the toml file: [[tool.poetry.source]]
name = "foo"
url = "https://pypi.org/" Then tried:
Full error:
|
If you have [[tool.poetry.source]]
name = "foo"
url = "https://pypi.org/" then you must then do |
Yeah, that was what I tried. My last comment could have been ordered in reverse since the third example was this approach.
|
Apologies for missing that last bit. I think I have a good idea what might be happening; can you try (note the new default line and the non-pypi name): [[tool.poetry.source]]
name = "foo"
url = "https://pypi.org/"
default = true Then do PyPi is special amongst repository peers in Poetry in that it bypasses my custom certificate logic. It also always gets consulted to see if a package is available. I believe it's probably doing the "foo" lookup correctly but, since you're squatting on the PyPi domain, the special PyPi lookup is failing. The |
Thanks, making progress! I created a new project Those steps appear to resolve the self-signed errors, but poetry appears unable to connect to pypi to identify package versions. Unseting the poetry configuration causes the self-signed errors to reappear
|
Ooh! Actually solved it, the path should be [[tool.poetry.source]]
name = "pypi_with_cert"
url = "https://pypi.org/project/"
default = true
Would it be useful to add this to the documentation somewhere? Edit: see comment below (#1012 (comment)), the url should be |
Hmm, I'm running into an error with those changes. Seems to work fine if the version specification matches the latest, but poetry can't identify prior versions. For example, changing the Create new project
Modify the toml file[tool.poetry]
name = "TestPyPiSelfSigned"
version = "0.1.0"
description = ""
authors = ["Kyle King"]
[[tool.poetry.source]]
name = "pypi_with_cert"
url = "https://pypi.org/project/"
default = true
[tool.poetry.dependencies]
python = "^3.7"
[tool.poetry.dev-dependencies]
pytest = "^4.0"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api" Try to install or update
|
Ok, final answer? Sorry for the spam. I believe we want the URL "https://pypi.org/simple/" (based on documentation from the Link class) poetry/poetry/packages/utils/link.py Line 17 in 6b09639
This now works[[tool.poetry.source]]
name = "pypi_with_cert"
url = "https://pypi.org/simple/"
default = true Then run: |
Huzzah! As a rule of thumb, you'll want /simple for most repositories. @sdispater: Do you have any strong feelings one way or the other about allowing a certificate authority override for PyPI? I'm happy to do a PR with the relevant changes if you're supportive. |
@Caligatio What is the use case for overriding the certificate authority for PyPI? |
Being behind a corporate firewall that does TLS interception |
Either what @jobec said or if you're in a corporate environment that squats on external domain names. My first thought on this is that it seems like a not-great security idea but, on the other hand, it would require explicit settings to enable and thus shouldn't be an accident. We got something working for @KyleKing in this thread but it wasn't exactly obvious what the actual problem was. |
TLS interception is usually done as a security measure. It allows to virus/threath scan what’s being downloaded. Whether it’s effective is a different discussion, but in many companies it’s a policy. And I agree, this can’t be configured by accident and you need to know how and where to get such root CA bundle. So the chance of abuse is low. |
Unfortunately, I'm not privy to what changed in the IT Infrastructure. There was a major overhaul in the last two years that caused us to start seeing the error "Self-Signed Certificate" whenever attempting to make a request with pip Creating a pem file isn't difficult, but you need to know the steps, so probably at least 60% of the people using this workaround would be my coworkers |
I couldn't get this to work on mac through the proxy. Pip is configured with our internal certificate and works fine but I can't even get poetry to install due to the self-signed certificate error. Are there any workarounds to install through proxy? |
@jerodg Are you having troubles installing poetry or installing packages using Poetry? If the prior, how you installing it? I typically use |
@Caligatio I can't even install it because of the proxy. I know this thread was mostly about packages but I didn't see any other issues relating to it. It throws a urllib error. |
This doesn't work as expected it seems.
It stores the certificate config in Manually copying the config from that file to the |
This is by design and reflects how PyPI auth tokens are stored. You typically wouldn't want to store the path to your private key in a public repository. One could argue a custom CA is more benign but I personally don't like revealing file names/paths.
|
Then it doesn't match with being able to configure a private repository on the project level but not configure it's root CA. |
Correct, you don't want to store anything related to custom certificate authorities/client certificates in the project configuration. Certificate authority handling and private certificates are on a per user per repository basis. If I clone your project but want to have the certificate file in a different location, I'm stuck. I can't really modify the pyproject.toml to change the path without possible merge conflicts. |
Alternatively, poetry should pick up certificates/certificate bundle path from pip config (user/system/site config) |
The certificate configuration works well when using PyPI. However, if a file is downloaded from
Setting the The following frame is from the requests library
If the verify parameter of the |
@bkeyser that's something of a misdiagnosis -- of course if you turn off SSL validation, it works. The issue is that Poetry can turn if off for pypi.org but we don't have a good mechanism to do it for files.pythonhosted.org which pypi.org hosts its files at. |
FWIW, I have serious issues with both installing Poetry itself and installing packages using poetry. As for the 1st part, I was eventually successful after a lot of messing around. I'm now stuck and unable to install packages using poetry. Here's an example of the error I get:
Note that I am having these issues when being behind corporate firewall/VPN. |
@drorata You can solve those by setting You can add a publishing-only repository to 'trick' Poetry into also trusting |
@neersighted For those of us who are behind a corporate firewall with a self-signed CA, could a default certificate be set? I don't fully understand the history, but it appears this approach might have been tried in #1325. However, this approach seems to contradict the comment
The |
The default certificate is
|
I want to share how I resolved this error with poetry. I am in a corporate environment, on windows10 and python 3.10. We have our own root CA certificate. A fresh install of Poetry 1.5 was giving me errors like this:
It's the same issue I faced with pip but I had managed to solve the ssl problem with pip by installing
Otherwise, you'll have to download the wheel and do a manual install first to get pip working. So what I did to fix Poetry was to go into poetry's venv and
After that, I exited the venv, went into my poetry project directory and used the poetry commands as normal and everything worked. |
This is the comment that finally helped me resolve my issues with poetry. Thank you |
@TranquilOasis can you give more detail on how pip-system-certs resolved your issues? After installing pip-system-certs in my global python install, as well as within poetry, I am still getting cert errors. Thanks! |
This is a duplicate of closed issue Specify SSL Cert for extra index server? #790
Feature Request
Allow and alternate root CA bundle to be specified from CLI and in the global/project settings file. Similar to how pip does it. This is crucial in environments where direct access to pypi is blocked and when using internal pypi mirrors with certificates signed by an internal root CA. Or with SSL traffic inspecting firewalls.
https://pip.pypa.io/en/stable/reference/pip/?highlight=proxy#cmdoption-cert
Having to set an environment variable like
REQUESTS_CA_BUNDLE
for an underlying package is not user-friendly and expects the user to know what poetry does under the hood.The text was updated successfully, but these errors were encountered: