mirror of
https://github.com/apple/pkl.git
synced 2026-01-13 15:13:38 +01:00
Fallback certificates do not work in certain classloader setups #343
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @netvl on GitHub (Sep 4, 2025).
In this piece of code:
a66ac0eb35/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/CliCommand.kt (L208-L225)the
org/pkl/commons/cli/PklCARoots.pemresource is resolved relatively to the classloader associated with the class returned byjavaClass. However, since this is an extension method forHttpClient.Builder, it means callingjavaClasson the builder instance, which is actually defined in the system classpath.Because of this, if the Pkl class is loaded by a different classloader compared to the one which contains JDK classes, which is totally possible in certain scenarios (e.g. with Gradle), then this resource resolution will fail.
The solution is to switch the
javaClasstarget tothis@CliCommandto load the resource using the classloader which loaded the jar with theCliCommandclass.