8

Maven发布封装到中央仓库时候报错:no default secret key: No secret key

 3 years ago
source link: http://blog.didispace.com/maven-gpg-expire/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Maven发布封装到中央仓库时候报错:no default secret key: No secret key

今天因为发布swagger-spring-boot-starter做一个问题的修复,然后碰到了下面这个问题,记录一下解决过程,帮助后续碰到类似问题的童鞋:

*gpg: WARNING: "--no-use-agent" is an obsolete option - it has no effect
gpg: no default secret key: No secret key
gpg: signing failed: No secret key

我们可以用gpg的命令来看一下当前密钥的情况:

$ gpg --list-keys
gpg: 正在检查信任度数据库
gpg: marginals needed: 3 completes needed: 1 trust model: pgp
gpg: 深度:0 有效性: 1 已签名: 0 信任度:0-,0q,0n,0m,0f,1u
/Users/zhaiyongchao/.gnupg/pubring.kbx
--------------------------------------
pub rsa2048 2017-12-05 [SC] [已过期:2019-12-05]
xxxxxxxxxxxxxxx
uid [已过期] zhaiyongchao <[email protected]>

可以看到原来设置的密钥对已经失效,所以下面就来使用gpg续订过期的密钥对:

第一步:进入密钥编辑

$ gpg --edit-key xxxxxxxxxxxxxxx
gpg (GnuPG) 2.2.3; Copyright (C) 2017 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.

私钥可用。

sec rsa2048/aaaaaaaaaaaaaaaa
创建于:2017-12-05 已过期:2019-12-05 可用于:SC
信任度:绝对 有效性:已过期
ssb rsa2048/bbbbbbbbbbbbbbbb
创建于:2017-12-05 已过期:2019-12-05 可用于:E
[已过期] (1). zhaiyongchao <[email protected]>

第二步:延长私钥与公钥的过期时间,并保存修改

gpg> expire
将要变更主钥的使用期限。
请设定这把密钥的有效期限。
0 = 密钥永不过期
<n> = 密钥在 n 天后过期
<n>w = 密钥在 n 周后过期
<n>m = 密钥在 n 月后过期
<n>y = 密钥在 n 年后过期
密钥的有效期限是?(0) 0
密钥永远不会过期
以上正确吗?(y/n)y

sec rsa2048/aaaaaaaaaaaaaaaa
创建于:2017-12-05 有效至:永不过期 可用于:SC
信任度:绝对 有效性:绝对
ssb rsa2048/bbbbbbbbbbbbbbbb
创建于:2017-12-05 已过期:2019-12-05 可用于:E
[ 绝对 ] (1). zhaiyongchao <[email protected]>

gpg: WARNING: Your encryption subkey expires soon.
gpg: You may want to change its expiration date too.

gpg> key 1

sec rsa2048/aaaaaaaaaaaaaaaa
创建于:2017-12-05 有效至:永不过期 可用于:SC
信任度:绝对 有效性:绝对
ssb* rsa2048/bbbbbbbbbbbbbbbb
创建于:2017-12-05 已过期:2019-12-05 可用于:E
[ 绝对 ] (1). zhaiyongchao <[email protected]>

gpg> expire
将要变更子钥的使用期限。
请设定这把密钥的有效期限。
0 = 密钥永不过期
<n> = 密钥在 n 天后过期
<n>w = 密钥在 n 周后过期
<n>m = 密钥在 n 月后过期
<n>y = 密钥在 n 年后过期
密钥的有效期限是?(0) 0
密钥永远不会过期
以上正确吗?(y/n)y

sec rsa2048/aaaaaaaaaaaaaaaa
创建于:2017-12-05 有效至:永不过期 可用于:SC
信任度:绝对 有效性:绝对
ssb* rsa2048/bbbbbbbbbbbbbbbb
创建于:2017-12-05 有效至:永不过期 可用于:E
[ 绝对 ] (1). zhaiyongchao <[email protected]>

gpg> save

到这里问题就解决了,可以再尝试一下mvn deploy来发布你的内容到中央仓库吧~


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK