Skip to content

Commit 40ee327

Browse files
committed
Test cleartext signature support in gpgme and sequoia backends
Currently, simple signatures are expected to be in the binary GPG format, and that's what e.g. `podman push --sign-by` produces as well. But the code for all backends work today with cleartext signatures. Add a new test to cover this case. But only in the GPGME and Sequoia backends since the OpenPGP backend does not support it and cannot easily be supported (see also [1]). The reason why I'm interested in this is that I'd like to make use of it for signing Fedora CoreOS container images. The end-goal is to move to Sigstore signing, but until that's ready, we'd like to use GPG signing. We use Robosignatory, the Fedora signing service, which only supports detached signatures, and while it's theoretically possible to convert the detached signatures we get back into inline binary signatures, it's much less cumbersome and error-prone to convert it to cleartext signatures. It's worth noting that while Fedora's signing server (Sigul) does support container image signing, Robosignatory does not surface it yet (see https://pagure.io/robosignatory/issue/22). Fixing that wouldn't be too hard I think, but all this is ideally short-term anyway until we can move to Sigstore signing + Konflux. There's work in progress on that (see e.g. https://discussion.fedoraproject.org/t/148999). The primary goal here is just ensuring that this keeps working until we move off of it. Signed-off-by: Jonathan Lebon <[email protected]> [1]: #307 (review)
1 parent 840390a commit 40ee327

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-----BEGIN PGP SIGNED MESSAGE-----
2+
Hash: SHA512
3+
4+
This is not JSON
5+
-----BEGIN PGP SIGNATURE-----
6+
Comment: generated with `gpg --homedir . --output invalid-cleartext.signature -u 08CD26E446E2E95249B7A405E932F44B23E8DD43 --clear-sign <<< "This is not JSON"`
7+
8+
iQGzBAEBCgAdFiEECM0m5Ebi6VJJt6QF6TL0SyPo3UMFAmi3YlcACgkQ6TL0SyPo
9+
3UMjQwv/TGivmwhYT8p9F5akuyZ0vkPhB+K4vr+M2VX1vIFGzL6edDWiiRYmysiY
10+
KtTdrRNnCZo6YbcOgdeL2OUpNWeoEshGhV0TqI/kstUa4vRs30NQ3kHX23+mcaf4
11+
iWI0RDmc05MHFXmOzMaWlb91hZBTGhHwvvPinqMg24QRNH1z1OEsuyJ2oBxdSj/Y
12+
dvGaSy0j8FimbfZS9mbf4+wfAUzkQi4PNBg+21l0QnEgl663VgcOQXK412WKNWcW
13+
vQkSXRFkpJNFF3lWjT4asiAV3T/KHUEq+QZE9rOa945wB0hoE7bZPx2hfZw4Se9/
14+
KH9O/ZM5WR5GyKbQV/ELNQJkJaDLcM56rBAl2l8eUV+bd8a7QrULjKP0dAffg8t8
15+
TKWyCSKddtiuJnuidCPV/A1iij0sZiSMzxb+Y33zgIrWThnfggpi0Oo9MYlF5hqF
16+
kD3b4zV1+7EW5YCEGT8sYhPpp96c1JnJbXZX2ii0KECdhLNB/iv44rSjOcl82nOY
17+
pa03tP/x
18+
=RDU4
19+
-----END PGP SIGNATURE-----

image/signature/mechanism_gpgme_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,17 @@ func TestGPGMESigningMechanismSupportsSigning(t *testing.T) {
4848
err = mech.SupportsSigning()
4949
assert.NoError(t, err)
5050
}
51+
52+
func TestGPGMESigningMechanismVerifyCleartext(t *testing.T) {
53+
mech, err := newGPGSigningMechanismInDirectory(testGPGHomeDirectory)
54+
require.NoError(t, err)
55+
defer mech.Close()
56+
57+
// Successful verification of a cleartext signature
58+
signature, err := os.ReadFile("./fixtures/invalid-cleartext.signature")
59+
require.NoError(t, err)
60+
content, signingFingerprint, err := mech.Verify(signature)
61+
require.NoError(t, err)
62+
assert.Equal(t, []byte("This is not JSON\n"), content)
63+
assert.Equal(t, TestKeyFingerprint, signingFingerprint)
64+
}

image/signature/mechanism_sequoia_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package signature
44

55
import (
6+
"os"
67
"testing"
78

89
"github.com/stretchr/testify/assert"
@@ -34,3 +35,17 @@ func TestSequoiaSigningMechanismSign(t *testing.T) {
3435
assert.Error(t, err)
3536
assert.IsType(t, SigningNotSupportedError(""), err)
3637
}
38+
39+
func TestSequoiaSigningMechanismVerifyCleartext(t *testing.T) {
40+
mech, err := newGPGSigningMechanismInDirectory(testGPGHomeDirectory)
41+
require.NoError(t, err)
42+
defer mech.Close()
43+
44+
// Successful verification of a cleartext signature
45+
signature, err := os.ReadFile("./fixtures/invalid-cleartext.signature")
46+
require.NoError(t, err)
47+
content, signingFingerprint, err := mech.Verify(signature)
48+
require.NoError(t, err)
49+
assert.Equal(t, []byte("This is not JSON\n"), content)
50+
assert.Equal(t, TestKeyFingerprint, signingFingerprint)
51+
}

0 commit comments

Comments
 (0)