我正在使用 maven-gpg-plugin 来签署 Maven Artifact 。这工作正常,但我的 GnuPG key 环中有几个 key ,并且想使用与 GnuPG 选择的 key 不同的 key 。
如果有多个键,GnuPG 如何选择“默认”键?
是否可以指定要在 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有关各个选项的更多详细信息:
- 使用
secretKeyring
选择专用 key 环 - 使用
homedir
选择专用的 GnuPG 主目录 - 通过
local-user
使用gpgArguments
的 GnuPG 选项
关于java - 如何选择 maven-gpg-plugin 用于签署 Artifact 的 GnuPG key ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32372363/