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

LibGit2: improve error when CA root cert can't be set #38827

Merged
merged 1 commit into from
Dec 15, 2020

Conversation

StefanKarpinski
Copy link
Sponsor Member

This addresses improving the error message in #38691.

This also fixes an insecure behavior: even if set_ssl_cert_locations failed, REFCOUNT was still incremented, so subsequent calls to ensure_initialized didn't call initialize and so there is never a successful call to set_ssl_cert_locations. Without this libgit2 defaults to not verifying host identities, which is insecure. To prevent this, this patch locks on ensure_initialized and decrements REFCOUNT if initialize throws an error, ensuring that initialize succeeds at least once, including the call to set_ssl_cert_locations.

@KristofferC KristofferC added the backport 1.6 Change should be backported to release-1.6 label Dec 11, 2020
@StefanKarpinski
Copy link
Sponsor Member Author

Working on adding some tests to this since doesn't seem to break anything.

@StefanKarpinski StefanKarpinski force-pushed the sk/libgit2-improve-ssl-cert-location-error branch from 904876b to f48bb3d Compare December 11, 2020 21:04
@StefanKarpinski
Copy link
Sponsor Member Author

Apparently LibGt2 does not error as expected with a bad (empty or non-existent) CA root certificates path on Linux AArch64. @Keno, are you the person to talk to about getting access to such a machine for debugging?

@Keno
Copy link
Member

Keno commented Dec 11, 2020

I can get you access to the buildbot, but that sounds like an issue with the docker container that actually runs the test, which is the domain of the great and powerful wizard @staticfloat .

@KristofferC KristofferC mentioned this pull request Dec 14, 2020
53 tasks
@StefanKarpinski
Copy link
Sponsor Member Author

This seems to work just fine when I'm actually logged into the aarch64 buildbot, so I don't get the failure.

@StefanKarpinski
Copy link
Sponsor Member Author

My working theory here is that some tests that use LibGit2 happened to get run in the same process before the LibGit2 tests, which would cause the library to already be initialized and therefore would cause the tests that expect initialization failure to fail to fail, as seen here. This wouldn't be specific to aarch64, which is supported by aarch64 tests passing when restarted, but means that I need to isolate these tests in a separate process.

This also fixes an insecure behavior: even if `set_ssl_cert_locations`
failed, `REFCOUNT` was still incremented, which meant that subsequent
calls to `ensure_initialized` didn't call `initialize` and so there was
never a successful call to `set_ssl_cert_locations`. Without this
libgit2 defaults to not verifying host identities and that is insecure.
To prevent this, this patch locks on `ensure_initialized` and decrements
`REFCOUNT` if initialize throws an error, ensuring that `initialize`
succeeds at least once, including the call to `set_ssl_cert_locations`.
@StefanKarpinski StefanKarpinski force-pushed the sk/libgit2-improve-ssl-cert-location-error branch from f48bb3d to 9b4b9c7 Compare December 14, 2020 21:29
@StefanKarpinski
Copy link
Sponsor Member Author

How is CI still running on this? Six hours and counting...

@Keno
Copy link
Member

Keno commented Dec 15, 2020

Linux32 has a long backlog

@StefanKarpinski StefanKarpinski merged commit 4dede6d into master Dec 15, 2020
@StefanKarpinski StefanKarpinski deleted the sk/libgit2-improve-ssl-cert-location-error branch December 15, 2020 14:38
KristofferC pushed a commit that referenced this pull request Dec 17, 2020
This also fixes an insecure behavior: even if `set_ssl_cert_locations`
failed, `REFCOUNT` was still incremented, which meant that subsequent
calls to `ensure_initialized` didn't call `initialize` and so there was
never a successful call to `set_ssl_cert_locations`. Without this
libgit2 defaults to not verifying host identities and that is insecure.
To prevent this, this patch locks on `ensure_initialized` and decrements
`REFCOUNT` if initialize throws an error, ensuring that `initialize`
succeeds at least once, including the call to `set_ssl_cert_locations`.

(cherry picked from commit 4dede6d)
@KristofferC KristofferC removed the backport 1.6 Change should be backported to release-1.6 label Dec 19, 2020
staticfloat pushed a commit that referenced this pull request Jan 15, 2021
This also fixes an insecure behavior: even if `set_ssl_cert_locations`
failed, `REFCOUNT` was still incremented, which meant that subsequent
calls to `ensure_initialized` didn't call `initialize` and so there was
never a successful call to `set_ssl_cert_locations`. Without this
libgit2 defaults to not verifying host identities and that is insecure.
To prevent this, this patch locks on `ensure_initialized` and decrements
`REFCOUNT` if initialize throws an error, ensuring that `initialize`
succeeds at least once, including the call to `set_ssl_cert_locations`.

(cherry picked from commit 4dede6d)
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this pull request May 4, 2021
This also fixes an insecure behavior: even if `set_ssl_cert_locations`
failed, `REFCOUNT` was still incremented, which meant that subsequent
calls to `ensure_initialized` didn't call `initialize` and so there was
never a successful call to `set_ssl_cert_locations`. Without this
libgit2 defaults to not verifying host identities and that is insecure.
To prevent this, this patch locks on `ensure_initialized` and decrements
`REFCOUNT` if initialize throws an error, ensuring that `initialize`
succeeds at least once, including the call to `set_ssl_cert_locations`.
staticfloat pushed a commit that referenced this pull request Dec 23, 2022
This also fixes an insecure behavior: even if `set_ssl_cert_locations`
failed, `REFCOUNT` was still incremented, which meant that subsequent
calls to `ensure_initialized` didn't call `initialize` and so there was
never a successful call to `set_ssl_cert_locations`. Without this
libgit2 defaults to not verifying host identities and that is insecure.
To prevent this, this patch locks on `ensure_initialized` and decrements
`REFCOUNT` if initialize throws an error, ensuring that `initialize`
succeeds at least once, including the call to `set_ssl_cert_locations`.

(cherry picked from commit 4dede6d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants