java - 如何选择 maven-gpg-plugin 用于签署 Artifact 的 GnuPG key ?

标签 java maven gnupg

我正在使用 maven-gpg-plugin 来签署 Maven Artifact 。这工作正常,但我的 GnuPG key 环中有几个 key ,并且想使用与 GnuPG 选择的 key 不同的 key 。

  1. 如果有多个键,GnuPG 如何选择“默认”键?

  2. 是否可以指定要在 maven-gpg-plugin 配置中使用的 key ? keyname 似乎不起作用(我假设它选择了 key 环,而不是特定的 key )。

最佳答案

How does GPG select the "default" key if there are several ones?

如果没有另外定义(例如,使用 default-key 选项),GnuPG 默认选择 key 环中的第一个 key 。来自 man gpg :

--default-key name

    Use name as the default key to sign with. If this option is not used,
    the default key is the first key found in the secret keyring. Note 
    that -u or --local-user overrides this option. 

Is there a possibility to specify the key to be used in the maven-gpg-plugin configuration? It seems that "keyname" doesn't work (I assume it selects the keyring, but not a specific key).

如果您不想让 GnuPG 自动决定使用哪个键,<keyname>[keyname]</keyname>选择要使用的键。我希望这作为 local-key 传递选项,因此它应该支持短 key ID 和长 key ID、指纹和用户 ID。 GnuPG 手册包含 list of ways to specify keys .

大多数描述如何在此处指定 key 的手册都使用短 key ID,我强烈建议不要这样做 because of collision attacks ,并改用整个指纹。

还有更多选项可以更改键的选择。引用Maven GnuPG plugin manual有关各个选项的更多详细信息:

关于java - 如何选择 maven-gpg-plugin 用于签署 Artifact 的 GnuPG key ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32372363/

相关文章:

git 验证可信标签

gnupg - gpg 列表键错误 trustdb 不可写

java - 单击 TableRowSorter 时获取所选行中的用户对象

java - 如何将 String 转换为 java.util.date 以便使其可插入 "DATE"类型的 mysql 数据库列?

java - 找不到 spring-aspects-4 依赖项

java - 将 Maven 依赖项添加到我的 Maven 项目时找不到资源

mysql - appfuse 快速入门不适用于 mysql

java - ALIGN_CENTER 无法解析或不是字段

Java 正则表达式 : Check in specific order

ssl - 受信任的 GPG 证书