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

Find the path to the certificate bundle in runtime #1135

Closed
wants to merge 1 commit into from

Conversation

moratom
Copy link

@moratom moratom commented Nov 5, 2024

The change makes the compiled library work on
different distributions, even if the path to the
certificate bundle in runtime is different compared to the path where it was during compilation.

This can be useful when the compilation is done on a manylinux Docker image which is based on CentOS, but the compiled library/binaries are used on
Ubuntu or Debian.

Related issue: curl/curl#11411

Maintainers of CURL were not interested in mainlining this, so I understand if this is not suitable for the default behavior, but it would be nice to be able to at least optionally turn that on in runtime.

The change makes the compiled library work on
different distributions, even if the path to the
certificate bundle in runtime is different compared
to the path where it was during compilation.

This can be useful when the compilation is done on
a manylinux Docker image which is based on CentOS,
but the compiled library/binaries are used on
Ubuntu or Debian.
@COM8
Copy link
Member

COM8 commented Nov 6, 2024

@moratom thanks for submitting this PR!
Sadly I have to say, I'm on the same side as the curl developers here.

cpr provides a way for you to set the ca path manually during runtime e.g. via:

cpr::SslOptions opts;
opts.ca_info = "/some/path.ca";

cpr::Response r =   cpr::Get(opts, ...);

So you can first probe which paths exist and then set them accordingly.

Using "random" paths on different distros is a security risk in case they are compromised since out of the box the directory structure has not the correct permissions set since this path is not intended to be used by this distro for that.

@COM8 COM8 closed this Nov 6, 2024
@moratom
Copy link
Author

moratom commented Nov 7, 2024

Thanks for taking a look @COM8!

Using "random" paths on different distros is a security risk in case they are compromised since out of the box the directory structure has not the correct permissions set since this path is not intended to be used by this distro for that.

That's a very good point.
Out of curiosity - is there a safer way from the top of your head to accomplish the same?

The specific use-case we have is that we use CPR&Curl in a project with Python bindings.

We provide manylinux wheels, which means we only compile once and it then generally works on most distributions. CPR/Curl is where this breaks as the wheels afterwards only work on Centos based distributions, but not on Ubuntu for example.
More accurately, the wheels still work, but the downloading feature doesn't.

@COM8
Copy link
Member

COM8 commented Nov 9, 2024

In my eyes this runtime check on startup is the only way. If you want to go the full way perhaps take /etc/os-release also into account for you educated ca path "guesses".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants