You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Railean, Alexander" <al...@siemens.com> on 2023/02/15 11:49:58 UTC

How to use a different signing mechanism with maven-gpg-plugin

Hi everyone,

 

I am looking for a way to use maven-gpg-plugin in conjunction with a
Hardware Security Module (HSM) for the process of publishing digitally
signed artifacts on Maven Central.

 

After reading the documentation I am under the impression that the plugin
assumes that it has the signing key and the passphrase - but in my use case
I rely on an external device to securely store the key, and the key itself
cannot get out of the device, by design.

 

After I sign the jar using utilities provided by the HSM, is there a way to
tell maven-gpg-plugin to use existing signature of the jar and upload it to
the server? (instead of trying to produce its own)

 

Alternatively, maybe you can recommend another approach that I can take?

 

Alex


RE: How to use a different signing mechanism with maven-gpg-plugin

Posted by "Railean, Alexander" <al...@siemens.com>.
Tamás, Martin - thank you for your quick feedback. It gave me certainty that the objective can be accomplished.


> if you can use your GPG CLI with your HSM, this could or should be possible, as maven-gpg-plugin really just invokes the CLI (the gpg executable).
The HSM doesn't provide such an option, but I can wrap its tool in a program called `gpg`, and mimic the command line interface of the real GPG. However, it sounds like Martin's approach would be simpler because it can use the files I already have.


> Hm, so signing the artifacts already works and you just want to install/deploy the signatures along with the JARs?
> Than I'd say build-helper-maven-plugin is what you need
Since I am new to the Java ecosystem, I couldn't figure out from the documentation of this plugin in what way I can apply it for my specific purpose. Thus, I looked for entry-level guides and made progress by following this one: https://central.sonatype.org/publish/publish-maven

They recommend using nexus-staging-maven-plugin. My starting state is with these files on my computer:

CmpRaComponent-2.2.2-SNAPSHOT.jar
CmpRaComponent-2.2.2-SNAPSHOT.jar.asc
CmpRaComponent-2.2.2-SNAPSHOT.jar.md5
CmpRaComponent-2.2.2-SNAPSHOT.jar.sha1
CmpRaComponent-2.2.2-SNAPSHOT.jar.sha256
CmpRaComponent-2.2.2-SNAPSHOT.jar.sha512
CmpRaComponent-2.2.2-SNAPSHOT-javadoc.jar
CmpRaComponent-2.2.2-SNAPSHOT-javadoc.jar.asc
CmpRaComponent-2.2.2-SNAPSHOT-javadoc.jar.md5
CmpRaComponent-2.2.2-SNAPSHOT-javadoc.jar.sha1
CmpRaComponent-2.2.2-SNAPSHOT-javadoc.jar.sha256
CmpRaComponent-2.2.2-SNAPSHOT-javadoc.jar.sha512
CmpRaComponent-2.2.2-SNAPSHOT-sources.jar
CmpRaComponent-2.2.2-SNAPSHOT-sources.jar.asc
CmpRaComponent-2.2.2-SNAPSHOT-sources.jar.md5
CmpRaComponent-2.2.2-SNAPSHOT-sources.jar.sha1
CmpRaComponent-2.2.2-SNAPSHOT-sources.jar.sha256
CmpRaComponent-2.2.2-SNAPSHOT-sources.jar.sha512
pom.xml, in the root directory of my project


Then I run `mvn jar:jar nexus-staging:deploy nexus-staging:deploy-staged`. It runs successfully and the logs show the data are uploaded to https://s01.oss.sonatype.org/content/repositories/snapshots/com/siemens/pki/CmpRaComponent/ - I can browse the directory structure, so it looks like it works.

However, the signature files are not there. I repeated the process one more time, while observing file-system i/o - I saw that *.asc are not read at all. Are there any other prerequisites that have to be met in order for this to work?

Looking forward to your additional clues,
Alex

Re: How to use a different signing mechanism with maven-gpg-plugin

Posted by Tamás Cservenák <ta...@cservenak.net>.
Howdy,

if you can use your GPG CLI with your HSM, this could or should be
possible, as maven-gpg-plugin really just invokes the CLI (the gpg
executable).

HTH
T

On Wed, Feb 15, 2023 at 12:50 PM Railean, Alexander <
alexander.railean@siemens.com> wrote:

> Hi everyone,
>
>
>
> I am looking for a way to use maven-gpg-plugin in conjunction with a
> Hardware Security Module (HSM) for the process of publishing digitally
> signed artifacts on Maven Central.
>
>
>
> After reading the documentation I am under the impression that the plugin
> assumes that it has the signing key and the passphrase – but in my use case
> I rely on an external device to securely store the key, and the key itself
> cannot get out of the device, by design.
>
>
>
> After I sign the jar using utilities provided by the HSM, is there a way
> to tell maven-gpg-plugin to use existing signature of the jar and upload it
> to the server? (instead of trying to produce its own)
>
>
>
> Alternatively, maybe you can recommend another approach that I can take?
>
>
>
> Alex
>

Re: How to use a different signing mechanism with maven-gpg-plugin

Posted by Martin Höller <ma...@xss.co.at>.
Hi!

On 15. Feb. 2023 Railean, Alexander wrote:
[...]
> After I sign the jar using utilities provided by the HSM, is there a way to
> tell maven-gpg-plugin to use existing signature of the jar and upload it to
> the server? (instead of trying to produce its own)
> 
> Alternatively, maybe you can recommend another approach that I can take?

Hm, so signing the artifacts already works and you just want to
install/deploy the signatures along with the JARs?

Than I'd say build-helper-maven-plugin is what you need:
http://www.mojohaus.org/build-helper-maven-plugin/attach-artifact-mojo.html

hth,
- martin