Fix set_ca_cert_store() to skip system certs like set_ca_cert_path() #2335
+22
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
set_ca_cert_path()andset_ca_cert_store()behave inconsistently regarding system certificate loading:set_ca_cert_path()set_ca_cert_store()Both APIs conceptually do the same thing: "use these CA certs for verification." However, when using
set_ca_cert_store()for certificate pinning, system certs are still loaded inload_certs(), defeating the purpose of pinning.Root Cause
In
load_certs():set_ca_cert_path()setsca_cert_file_path_, taking the first branch and skipping system cert loading.set_ca_cert_store()setsca_cert_store_(since #2217 fix), butload_certs()doesn't check it, so it falls through to the else branch where system certs are added to the user's custom store.Fix
Check
ca_cert_store_inload_certs():This makes
set_ca_cert_store()behave consistently withset_ca_cert_path().Test
Added
SSLClientTest.SetCaCertStoreSkipsSystemCerts_Onlineto verify system certs are not loaded when custom store is set.