Sops failed when "--keyservice" used ERROR: Could not load secring: open /root/.gnupg/secring.gpg
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.1k
- Forks
- 1.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 9
Description
I think the issue in the https://github.com/mozilla/sops/blob/master/pgp/keysource.go line:302
func (key *MasterKey) secRing() (openpgp.EntityList, error) {
return key.loadRing(key.gpgHome() + "/secring.gpg")
}
but based on official GnuPG Documentation:
~/.gnupg/secring.gpg
A secret keyring as used by GnuPG versions before 2.1. It is not used by GnuPG 2.1 and later.
~/.gnupg/secring.gpg.lock
The lock file for the secret keyring.
https://www.gnupg.org/documentation/manuals/gnupg/GPG-Configuration.html
ERROR:
sops --keyservice tcp://127.0.0.1:5000 --enable-local-keyservice=false test1.yaml
Failed to get the data key required to decrypt the SOPS file.
Group 0: FAILED
C2CD75E650166658638EDFBA2E3081C34794EF92: FAILED
- | rpc error: code = Unknown desc = could not decrypt data key
| with PGP key: golang.org/x/crypto/openpgp error: Could not
| load secring: open /root/.gnupg/secring.gpg: no such file or
| directory; GPG binary error: exit status 2
Recovery failed because no master key was able to decrypt the file. In
order for SOPS to recover the file, at least one key has to be successful,
but none were.
My .gnupg/ dir contain followed files:
drwx------. 2 root root 21 Nov 7 09:17 crls.d
drwx------. 2 root root 162 Nov 7 09:32 openpgp-revocs.d
drwx------. 2 root root 110 Nov 7 09:32 private-keys-v1.d
-rw-r--r--. 1 root root 8828 Nov 7 09:32 pubring.kbx
-rw-r--r--. 1 root root 6376 Nov 7 09:30 pubring.kbx~
-rw-r-----. 1 root root 676 Nov 7 09:14 sshcontrol
-rw-------. 1 root root 1440 Nov 7 09:35 trustdb.gpg
Versions:
OS: CentOS 8
SOPS: sops 3.4.0 (latest)
GnuPG: gpg (GnuPG) 2.2.9
libgcrypt 1.8.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pgp/keysource.go at MasterKey.secRing and loadRing, then reproduce the failure with the shown sops --keyservice command. Compare the key-loading path with the reported GnuPG 2.2 keyring layout. Done means decryption no longer fails because /root/.gnupg/secring.gpg is missing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100