-
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
Further SSL problems with Poetry and a private Gitlab package registry #4016
Comments
The problem seems to be missing cert in your system bundle and when you set the env var the default bundles being disabled. Does setting a custom cert help here? There was also a fix (on master) related to this config. Also you should consider adding via |
I'm not sure I'm following your logic on the missing cert, but I also think I'm missing some understanding on how poetry is expecting certificates to be presented to it. Working this through... The It is the same AFAIK there's no client certificate needed to authenticate to the Gitlab (I've had no git related SSL issues, nor regular browser related login issues), so
... and it broke things in a different way (which I kind of expected since those CA certs aren't client certs) For those searching, that break looks like:
By removing the lines from
So, looking at that and at https://stackoverflow.com/questions/51925384/unable-to-get-local-issuer-certificate-when-using-requests-in-python, I've added the root and inter ca's to the certifi Stepping back and trying the method Gitlab help suggests (i.e.
If I visit the URL in a browser (https://oxnetcnsc01.oxnet.nhs.uk/api/v4/projects/202/packages/pypi/simple/atlas-models/ - behind a firewall so this won't work for external/internet access) I am prompted for my username + token login details, and then presented with a list of packages (.tar.gz and .whl files for atlas-models) and if I click on the wheel link, then it downloads the wheel file just fine. Looking in the browser I can see a valid certificate chain for the custom root, inter, and server certificates. So if I'm understanding your first line @abn - I need to figure out which certificate bundle that python is using because that appears to be the weak link here; it also seems that poetry is ignoring the certificates I'm setting as custom for this |
Fixed it! https://stackoverflow.com/a/57795811 provided the clue here. Following on from the
to my
I'm still confused as to why |
I hope it is ok to piggyback on this ticket.
Than I added a section in my
If I run a
If I just remove the It looks like setting any certificate in the config overrides the my system certificate and the workaround from marshalc does not work for me setting SSL_CERT_FILE or REQUESTS_CA_BUNDLE to a valid certificate bundle does not change the behavior. |
I'm experiencing the same issue on poetry 1.1.8 but I have a patch to solve this. The problem is that by default, the requests library doesn't retry when a connection fails, and the custom poetry CacheControlAdapter also doesn't pass any retry parameters. Once the patch is done, I'll ask a merge request to fix this issue. In our case this issue only arises on Windows which is behind an enterprise proxy, but not on Linux, but as most developers work on Windows machines, we needed to fix this issue. We didn't experience this issue with poetry 1.0.10 though. |
Okay, I was having this same issue, and have found exactly what the cause is (at least in my case.) When determining what repository is associated with a given url, it compares the netloc of the registered custom repository to the netloc of the given url to fetch. poetry/src/poetry/utils/authenticator.py Line 397 in bf0dbc0
The problem is that gitlab tells you to set up your custom repository url including an username and password, e.g. I think the proper solution would be to adjust the poetry authentcator utility to only compare the hostname and port, rather than the whole netloc when determining what certs to use. |
I also had this problem. In the end I fixed it for me with removing the
Additional I used the fix from marshalc to set the explicit certificate store and added the missing certificate to the
|
-vvv
option).Issue
Closely related to #745 and #1012, I am experiencing problems working with poetry against a private (Gitlab) based package registry, on an internal project. The locked nature of this make this very hard for me to do a public replication of the problem, so apologies whilst I have to be descriptive (if a little vague for some sensitive info).
I have two poetry based python+django projects. The first (
atlas-models
) I have managed to package as a reusable app, and build and publish (with just poetry) to our internal Gitlab Package Registry. Presently there are two versions of the package in the registry (but I've tried with between 1 & 3 versions there, that doesn't appear to be a factor).In my second project, when I attempt to add the first package via
poetry add atlas-models -vvv
, I get the following (abbreviated) output:The
pyproject.toml
reads as:Additionally,
poetry config --list -vvv
results in:I have also done
poetry config http-basic.pages-oxnet user.name token-code
for both.pages-oxnet
and.pages-oxnet-atlas
. This was all pretty much put in place to get the build and publish workflows to succeed. I also addedcertificates.oxnetcnsc01.cert
andhttp-basic.oxnetcnsc01
as well to ensure I hadn't overlooked anything.I can see that the process is locating the latest version of the
atlas-models
package from the gitlab private registry, but is clearly having a problem with downloading the wheel file.The SSL certificates you can see in the config output above are seemingly valid as they resolved the publish SSL connection issues.
If I try to set the environment variable though (to catch a potential issue with requests as suggested in an earlier bug report), I get a whole host of different errors, i.e.:
export REQUESTS_CA_BUNDLE=/Users/carl/Projects/pages.oxnet/oxnet-combined.pem
followed bypoetry add atlas-models -vvv
results in a much faster set of errors:When I
unset REQUESTS_CA_BUNDLE
and retry the add command, we're back to the original error outputs and timeout.I am now at a loss of what else to try here. Something appears to be partly broken in the process of adding my package from the internal registry, and this is now stalling my whole development plan. I don't really want to have to remove poetry from this setup, but I do note there's very little Gitlab recognition of Poetry usage (none in their own documentation) and most examples I'm finding at either general pip or GitHub solutions.
Please let me know if there's any other practical tests, or configuration I can attempt, or if this is enough information on which to diagnose a bug.
Thank you for your time and help.
The text was updated successfully, but these errors were encountered: