mirror of
https://github.com/apple/pkl.git
synced 2026-03-26 11:01:14 +01:00
Do not enable TLS certificate revocation checks by default (#553)
This addresses an issue where network requests may fail if cert revocation checks error, which may occur due to availability issues, or due to lack of internet access. Revocation checking can still be enabled by setting JVM property com.sun.net.ssl.checkRevocation if on the JVM. Also: * Load built-in certs from resources, and move them to pkl-commons-cli * Fix an issue where HttpInitException is not caught when loading a module
This commit is contained in:
@@ -171,8 +171,20 @@ abstract class CliCommand(protected val cliOptions: CliBaseOptions) {
|
||||
|
||||
private fun HttpClient.Builder.addDefaultCliCertificates() {
|
||||
val caCertsDir = IoUtils.getPklHomeDir().resolve("cacerts")
|
||||
var certsAdded = false
|
||||
if (Files.isDirectory(caCertsDir)) {
|
||||
Files.list(caCertsDir).filter { it.isRegularFile() }.forEach { addCertificates(it) }
|
||||
Files.list(caCertsDir)
|
||||
.filter { it.isRegularFile() }
|
||||
.forEach { cert ->
|
||||
certsAdded = true
|
||||
addCertificates(cert)
|
||||
}
|
||||
}
|
||||
if (!certsAdded) {
|
||||
val defaultCerts =
|
||||
javaClass.classLoader.getResourceAsStream("org/pkl/commons/cli/PklCARoots.pem")
|
||||
?: throw CliException("Could not find bundled certificates")
|
||||
addCertificates(defaultCerts.readAllBytes())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.pkl.commons.cli
|
||||
|
||||
import java.io.PrintStream
|
||||
import java.security.Security
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
/** Building block for CLIs. Intended to be called from a `main` method. */
|
||||
@@ -30,9 +29,6 @@ fun cliMain(block: () -> Unit) {
|
||||
|
||||
// Force `native-image` to use system proxies (which does not happen with `-D`).
|
||||
System.setProperty("java.net.useSystemProxies", "true")
|
||||
// enable OCSP for default SSL context
|
||||
Security.setProperty("ocsp.enable", "true")
|
||||
|
||||
try {
|
||||
block()
|
||||
} catch (e: CliTestException) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user