我正在尝试在Central Repository中发布我的maven项目,我需要签署我的工件。我已经下载并安装了gpg并创建了我的密钥环。当我在Eclipse中运行“maven clean deploy”时,我收到以下错误:
gpg: no default secret key: No secret key
gpg: signing failed: No secret key
我在网上搜索过,我不知道该怎么做。我的pom.xml文件中唯一关于gpg的参考是
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
谢谢!
答案 0 :(得分:2)
我刚刚遇到了相同的错误消息。在我的情况下,这是由密钥过期引起的,如以下命令所示:
six-58:tmp hot$ gpg --list-keys
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
/Users/hot/.gnupg/pubring.gpg
-----------------------------
pub 2048R/236D3BEF 2016-12-30 [expired: 2018-12-30]
uid Holger Thurow <...@gmail.com>
请注意“ [已过期:2018-12-30]”。
这是我解决问题的方法:
six-58:tmp hot$ gpg --edit-key 236D3BEF
gpg (GnuPG) 1.4.19; Copyright (C) 2015 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Secret key is available.
pub 2048R/236D3BEF created: 2016-12-30 expired: 2018-12-30 usage: SC
trust: ultimate validity: expired
sub 2048R/450709B5 created: 2016-12-30 expired: 2018-12-30 usage: E
[ expired] (1). Holger Thurow <...@gmail.com>
gpg> 1
pub 2048R/236D3BEF created: 2016-12-30 expired: 2018-12-30 usage: SC
trust: ultimate validity: expired
sub 2048R/450709B5 created: 2016-12-30 expired: 2018-12-30 usage: E
[ expired] (1)* Holger Thurow <...@gmail.com>
gpg> expire
Changing expiration time for the primary key.
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y
You need a passphrase to unlock the secret key for
user: "Holger Thurow <...@gmail.com>"
2048-bit RSA key, ID 236D3BEF, created 2016-12-30
pub 2048R/236D3BEF created: 2016-12-30 expires: never usage: SC
trust: ultimate validity: ultimate
sub 2048R/450709B5 created: 2016-12-30 expired: 2018-12-30 usage: E
[ultimate] (1)* Holger Thurow <...@gmail.com>
gpg> save
请参见here中详细描述的“处理过期的密钥”。
答案 1 :(得分:1)
这个问题很久以前就被问过了,我不记得我到底做了什么来修复它。我记得我的settings.xml
文件中有拼写错误。这是我在文件中更改的内容:
<profile>
<id>sign</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.passphrase>password</gpg.passphrase>
</properties>
</profile>
这现在有效。