JAVA-6187 Upgrade libcrypt version to 1.18.1#1983
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the mongodb-crypt module’s bundled libmongocrypt native library download process to use libmongocrypt’s 1.18.1 GitHub release assets (instead of S3) and adds GPG signature verification of the downloaded tarballs.
Changes:
- Bump libmongocrypt download revision to
1.18.1and switch download base URL to GitHub releases. - Download per-platform tarballs (+
.ascsignatures) and extract only the needed native library into the JNA resources directory. - Add a Gradle task that verifies tarball signatures via
gpg, with an opt-out via-PskipCryptVerify=true.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| val tarballList = tarballs.files.toList() | ||
| val signatureList = signatures.files.toList() | ||
| check(tarballList.size == signatureList.size) { | ||
| "Expected each tarball to have a matching signature: ${tarballList.size} tarballs vs ${signatureList.size} signatures." | ||
| } | ||
| tarballList.zip(signatureList).forEach { (tarball, signature) -> |
| setExecutable(true, true) | ||
| } | ||
|
|
||
| execOps.exec { commandLine("gpg", "--homedir", home.path, "--batch", "--import", publicKey.get().asFile.path) } |
There was a problem hiding this comment.
let's skip it for now, as we know that we are downloading from a trusted source
| abstract class VerifyLibmongocryptTask : DefaultTask() { | ||
| @get:Inject abstract val execOps: ExecOperations | ||
|
|
||
| @get:InputFiles abstract val tarballs: ConfigurableFileCollection | ||
| @get:InputFiles abstract val signatures: ConfigurableFileCollection | ||
| @get:InputFile abstract val publicKey: RegularFileProperty | ||
| @get:Input abstract val skipVerify: Property<Boolean> | ||
|
|
| execOps.exec { | ||
| commandLine("gpg", "--homedir", home.path, "--batch", "--verify", signature.path, tarball.path) |
There was a problem hiding this comment.
| execOps.exec { | |
| commandLine("gpg", "--homedir", home.path, "--batch", "--verify", signature.path, tarball.path) | |
| execOps.exec { | |
| commandLine("gpg", "--homedir", home.path, "--batch", "--trust-model", "always", "--quiet", "--verify", signature.path, tarball.path) | |
| } |
Will reduce the noise from gpg
| setExecutable(true, true) | ||
| } | ||
|
|
||
| execOps.exec { commandLine("gpg", "--homedir", home.path, "--batch", "--import", publicKey.get().asFile.path) } |
There was a problem hiding this comment.
| execOps.exec { commandLine("gpg", "--homedir", home.path, "--batch", "--import", publicKey.get().asFile.path) } | |
| execOps.exec { commandLine("gpg", "--homedir", home.path, "--batch", "--quiet", "--import", publicKey.get().asFile.path) } |
Added the quiet flag to reduce noise
rozza
left a comment
There was a problem hiding this comment.
Like this. Couple of optional suggestions.
You may want to change the task names downloadJava no longer makes sense as it used to be the java tarball. For example: downloadCryptLibs, verifyCryptLibs and extractCryptLibs make more sense now than downloadJava, verifyJava and unzipJava.
One gripe from the existing implementation, you might want to make downloading optional eg:
overwrite(false)
onlyIf { !file("$jnaDownloadsDir/${platform.tarballName}.tar.gz").exists() }
That way it would work without having to check if modified and offline. Also we can bypass this all if jnaLibsPath is set.
JAVA-6187
Upgrading libcrypt version to 1.18.1
Also the artifact location got changed from s3 to github
Risks
This PR assumes there is
gpginstalled that might not be a case in WindowsResolution of risks
There is a new flag
-PskipCryptVerify=truethat will skipgpgverificationWarnings (not applicable, I passed --quite as suggested by Ross)
If you run
./gradlew :mongodb-crypt:downloadJnaLiblocally it will give a few warningsThe reason is because gpg doesn't know if the key is trusted as we arbitrary downloaded it
Running the same command using shell will give the same output
