Skip to content

Commit a9f6da9

Browse files
committed
chore: update the signature verification process for the relays manifest file
1 parent 41eb69b commit a9f6da9

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

pkg/verification/constants.go

-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ package verification
33
const NodeTecKeybasePGPKeyURL = "https://keybase.io/nodetec/pgp_keys.asc"
44
const RelaysManifestFileURL = "https://github.com/nodetec/relays/releases/download/v0.4.0/relays-0.4.0-manifest.sha512sum"
55
const RelaysManifestSigFileURL = "https://github.com/nodetec/relays/releases/download/v0.4.0/relays-0.4.0-manifest.sha512sum.asc"
6-
const NodeTecGoodSigMsg = `Good signature from "NODE-TEC Devs <devs@node-tec.com>"`
7-
const NodeTecPrimaryKeyFingerprint = "04BD8C20598FA5FDDE19BECD8F2469F71314FAD7"
86
const NodeTecSigningSubkeyFingerprint = "252F57B9DCD920EBF14E6151A8841CC4D10CC288"

pkg/verification/verify.go

+6-21
Original file line numberDiff line numberDiff line change
@@ -46,37 +46,22 @@ func VerifyRelayBinary(path string) {
4646
// Download and copy the file
4747
files.DownloadAndCopyFile(relaysManifestFilePath, RelaysManifestFileURL)
4848

49-
// Use GPG to verify the manifest signature file and output the primary key and signature subkey fingerprints
50-
cmd := exec.Command("gpg", "--verify", "--with-fingerprint", "--with-subkey-fingerprints", relaysManifestSigFilePath)
49+
// Use GPG to verify the manifest signature file
50+
out, err := exec.Command("gpg", "--status-fd", "1", "--verify", relaysManifestSigFilePath).Output()
5151

52-
out, err := cmd.CombinedOutput()
5352
if err != nil {
5453
pterm.Println()
5554
pterm.Error.Println(fmt.Sprintf("Failed to run the gpg verify command on the %s file: %v", relaysManifestSigFilePath, err))
5655
os.Exit(1)
5756
}
5857

59-
gpgVerifyOutput := string(out)
58+
validSig := strings.Contains(string(out), fmt.Sprintf("[GNUPG:] VALIDSIG %s", NodeTecSigningSubkeyFingerprint))
6059

61-
goodSig := strings.Contains(gpgVerifyOutput, NodeTecGoodSigMsg)
62-
63-
// Extract the formatted primary key and formatted signature subkey fingerprints from the output
64-
_, formattedPrimaryAndSubKeyFingerprints, _ := strings.Cut(gpgVerifyOutput, "Primary key fingerprint: ")
65-
66-
formattedPrimaryKeyFingerprint, formattedSubkeyFingerprint, _ := strings.Cut(formattedPrimaryAndSubKeyFingerprints, "Subkey fingerprint: ")
67-
68-
// Remove the spaces and new line characters from the formatted primary key and formatted signature subkey fingerprints
69-
formattedPrimaryKeyFingerprint = strings.ReplaceAll(formattedPrimaryKeyFingerprint, " ", "")
70-
formattedSubkeyFingerprint = strings.ReplaceAll(formattedSubkeyFingerprint, " ", "")
71-
72-
primaryKeyFingerprint := strings.ReplaceAll(formattedPrimaryKeyFingerprint, "\n", "")
73-
subkeyFingerprint := strings.ReplaceAll(formattedSubkeyFingerprint, "\n", "")
74-
75-
if goodSig && primaryKeyFingerprint == NodeTecPrimaryKeyFingerprint && subkeyFingerprint == NodeTecSigningSubkeyFingerprint {
76-
spinner.UpdateText(fmt.Sprintf("Verified the signature of the %s file and the fingerprints", relaysManifestFilePath))
60+
if validSig {
61+
spinner.UpdateText(fmt.Sprintf("Verified the signature of the %s file", relaysManifestFilePath))
7762
} else {
7863
pterm.Println()
79-
pterm.Error.Println(fmt.Sprintf("Failed to verify the signature of the %s file and/or the fingerprints", relaysManifestFilePath))
64+
pterm.Error.Println(fmt.Sprintf("Failed to verify the signature of the %s file", relaysManifestFilePath))
8065
os.Exit(1)
8166
}
8267

0 commit comments

Comments
 (0)