Skip to content

Commit 47aa231

Browse files
author
Ales Bregar
committed
updating REST api with multiple gpg keys support, due backwards compatibility introducing CSV under same key (gpg-key)
1 parent 7166330 commit 47aa231

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

api/publish.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
type signingParams struct {
1717
// Don't sign published repository
1818
Skip bool ` json:"Skip" example:"false"`
19-
// GPG key ID to use when signing the release, if not specified default key is used
20-
GpgKey string ` json:"GpgKey" example:"A0546A43624A8331"`
19+
// GPG key ID(s) to use when signing the release, CSV if multiple keys, if not specified default configured key(s) are used
20+
GpgKey string ` json:"GpgKey" example:"KEY_ID_a,KEY_ID_b"`
2121
// GPG keyring to use (instead of default)
2222
Keyring string ` json:"Keyring" example:"trustedkeys.gpg"`
2323
// GPG secret keyring to use (instead of default) Note: depreciated with gpg2
@@ -41,7 +41,21 @@ func getSigner(options *signingParams) (pgp.Signer, error) {
4141
}
4242

4343
signer := context.GetSigner()
44-
signer.SetKey(options.GpgKey)
44+
45+
var multiGpgKeys []string
46+
// REST params have priority over config
47+
if options.GpgKey != "" {
48+
for _, p := range strings.Split(options.GpgKey, ",") {
49+
if t := strings.TrimSpace(p); t != "" {
50+
multiGpgKeys = append(multiGpgKeys, t)
51+
}
52+
}
53+
} else if len(context.Config().GpgKeys) > 0 {
54+
multiGpgKeys = context.Config().GpgKeys
55+
}
56+
for _, gpgKey := range multiGpgKeys {
57+
signer.SetKey(gpgKey)
58+
}
4559
signer.SetKeyRing(options.Keyring, options.SecretKeyring)
4660
signer.SetPassphrase(options.Passphrase, options.PassphraseFile)
4761

docs/Publish.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ Public part of the key should be exported from your keyring using `gpg --export
2525
```
2626
aptly publish repo my-repo --gpg-key=KEY_ID_a --gpg-key=KEY_ID_b
2727
```
28-
* If `--gpg-key` is specified on the command line, it takes precedence over any gpgKeys configuration in `aptly.conf`.
28+
* When using the REST API, the `gpgKey` parameter supports a comma-separated list of key IDs:
29+
```
30+
"gpgKey": "KEY_ID_a,KEY_ID_b"
31+
```
32+
* If `--gpg-key` is specified on the command line, or `gpgKey` is provided via the REST API, it takes precedence over any gpgKeys configuration in aptly.conf.
2933
* With multi-key support, aptly will sign all Release files (both clearsigned and detached signatures) with each provided key, ensuring a smooth key rotation process while maintaining compatibility for existing clients.
3034

3135
#### Parameters

0 commit comments

Comments
 (0)