NIFI-15675 - Add NAR signing support using JDK JarSigner - #48
pvillard31 wants to merge 2 commits into
Conversation
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for proposing this addition @pvillard31, supporting the ability to sign a NAR aligns well with general JAR signing features. I plan to take a closer look at the implementation soon.
There was a problem hiding this comment.
@pvillard31 Returning to this pull request after some time, I'm wondering if it is still necessary. Artifact signing for NAR files can be accomplishing using the existing maven-jarsigner-plugin, which has several advantages. The current PR uses SHA-256 instead of SHA-384, and does not perform any certificate validation, both of which are default behavior in the JAR Signer plugin.
The Nar-Signed-By entry would be different than the corresponding JAR entry, but in this case, it seems better to align with JAR signing than introduce something new. Are there any other reasons to proceed with this kind of implementation within the NAR Plugin itself?
https://issues.apache.org/jira/browse/NIFI-15675
Add NAR signing support using JDK JarSigner
When NiFi dynamically downloads or auto-loads NARs from external sources, there is currently no mechanism to verify that a NAR has not been tampered with or that it originates from a trusted publisher. This is the build-side prerequisite for enabling signature verification in the NiFi runtime.
Since a NAR is structurally a JAR, the JDK's built-in JAR signing mechanism is the natural fit. This issue covers adding optional signing parameters to the existing goal in the plugin. Signing is disabled by default for full backward compatibility. A follow-up issue will cover runtime verification in NiFi itself.
nargoal using the JDK'sjdk.security.jarsigner.JarSignerAPInar.sign=false) — fully backward compatible, no behavioral change unless explicitly opted increateArchive()produces the NAR, the newsignNar()step signs it in place using the configured keystore, then the signed NAR is registered as the project artifactConfiguration
Seven new parameters on the
nargoal, all optional:signnar.signfalsesignKeystorenar.sign.keystoresignStorepassnar.sign.storepasssignAliasnar.sign.aliassignKeypassnar.sign.keypasssignStoretypenar.sign.storetypePKCS12signTsanar.sign.tsaMinimal usage:
Or entirely via command line with no POM changes:
Signed NARs can be verified with standard JDK tooling:
jarsigner -verify -verbose -certs target/my.narApproach
A NAR is structurally a JAR. Rather than inventing a custom signature format, this uses the JDK's
JarSignerAPI (available since Java 9, stable in Java 21) which signs each entry inside the archive with SHA-256 digests and produces standard PKCS#7 signature blocks. This means:jarsigner -verifyby anyonejdk.security.jarsigner.JarSigneris part of the JDK itselfMETA-INF/like any signed JARVerification building nifi-aws-nar
NAR build
NAR content
Verification
Manifest