fix(npm): support npmrc certfile + keyfile#32655
Conversation
dc1294e to
b430795
Compare
b430795 to
cde33be
Compare
|
Force-pushed the same commit to re-trigger the CI, as previous build failed with some strange CI-related error. |
kajukitli
left a comment
There was a problem hiding this comment.
lgtm, good fix
threading RegistryConfig all the way down to the npm cache http client is the right shape. otherwise there was no place to decide whether a request needed a client-cert-backed client.
the per-(certfile,keyfile) client cache in HttpClientProvider also makes sense — you don't want to rebuild a TLS client for every packument/tarball fetch.
nice that you covered both the happy path (mTLS registry) and the missing-certfile error path.
one minor thing: get_or_create_with_client_cert() uses to_string_lossy() for the cache key, so weird non-utf8 paths could alias. probably irrelevant in practice, but if you want to be strict you could key by PathBuf instead of lossy strings.
Closes #23951
This PR implements the missing support for
certfileandkeyfileoptions. Now when both are set, it creates an HTTP client with the client certificate attached.Also added two new tests and a new mTLS-enabled test registry:
npmrc_certfile- installs a package from an https registry that requires a valid client certificatenpmrc_missing_certfile- verifies an error when thecertfilepath doesn't exist