@@ -14,18 +14,6 @@ import (
14
14
15
15
// Function to verify relay binaries
16
16
func VerifyRelayBinary (path string ) {
17
- ThemeDefault := pterm .ThemeDefault
18
-
19
- prompt := pterm.InteractiveContinuePrinter {
20
- DefaultValueIndex : 0 ,
21
- DefaultText : "Do you want to continue with the installation?" ,
22
- TextStyle : & ThemeDefault .PrimaryStyle ,
23
- Options : []string {"no" , "yes" },
24
- OptionsStyle : & ThemeDefault .SuccessMessageStyle ,
25
- SuffixStyle : & ThemeDefault .SecondaryStyle ,
26
- Delimiter : ": " ,
27
- }
28
-
29
17
spinner , _ := pterm .DefaultSpinner .Start ("Verifying relay binary..." )
30
18
pterm .Println ()
31
19
@@ -58,7 +46,8 @@ func VerifyRelayBinary(path string) {
58
46
// Download and copy the file
59
47
files .DownloadAndCopyFile (relaysManifestFilePath , RelaysManifestFileURL )
60
48
61
- cmd := exec .Command ("gpg" , "--verify" , relaysManifestSigFilePath )
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 )
62
51
63
52
out , err := cmd .CombinedOutput ()
64
53
if err != nil {
@@ -71,33 +60,24 @@ func VerifyRelayBinary(path string) {
71
60
72
61
goodSig := strings .Contains (gpgVerifyOutput , NodeTecGoodSigMsg )
73
62
74
- // Extract the formatted primary key and subkey fingerprints from the output
75
- _ , formattedPrimaryAndSubKeyFingerprints , foundPrimaryKeyText := strings .Cut (gpgVerifyOutput , "Primary key fingerprint: " )
63
+ // Extract the formatted primary key and formatted signature subkey fingerprints from the output
64
+ _ , formattedPrimaryAndSubKeyFingerprints , _ := strings .Cut (gpgVerifyOutput , "Primary key fingerprint: " )
76
65
77
- formattedPrimaryKeyFingerprint , formattedSubkeyFingerprint , foundSubkeyText := strings .Cut (formattedPrimaryAndSubKeyFingerprints , "Subkey fingerprint: " )
66
+ formattedPrimaryKeyFingerprint , formattedSubkeyFingerprint , _ := strings .Cut (formattedPrimaryAndSubKeyFingerprints , "Subkey fingerprint: " )
78
67
79
- if foundPrimaryKeyText && foundSubkeyText {
80
- formattedPrimaryKeyFingerprint = strings .ReplaceAll (formattedPrimaryKeyFingerprint , " " , "" )
81
- formattedSubkeyFingerprint = strings .ReplaceAll (formattedSubkeyFingerprint , " " , "" )
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 , " " , "" )
82
71
83
- primaryKeyFingerprint := strings .ReplaceAll (formattedPrimaryKeyFingerprint , "\n " , "" )
84
- subkeyFingerprint := strings .ReplaceAll (formattedSubkeyFingerprint , "\n " , "" )
72
+ primaryKeyFingerprint := strings .ReplaceAll (formattedPrimaryKeyFingerprint , "\n " , "" )
73
+ subkeyFingerprint := strings .ReplaceAll (formattedSubkeyFingerprint , "\n " , "" )
85
74
86
- if goodSig && primaryKeyFingerprint == NodeTecPrimaryKeyFingerprint && subkeyFingerprint == NodeTecSigningSubkeyFingerprint {
87
- spinner .UpdateText (fmt .Sprintf ("Verified the signature of the %s file and the fingerprints" , relaysManifestFilePath ))
88
- } else {
89
- pterm .Println ()
90
- pterm .Error .Println (fmt .Sprintf ("Failed to verify the signature of the %s file" , relaysManifestFilePath ))
91
- os .Exit (1 )
92
- }
75
+ if goodSig && primaryKeyFingerprint == NodeTecPrimaryKeyFingerprint && subkeyFingerprint == NodeTecSigningSubkeyFingerprint {
76
+ spinner .UpdateText (fmt .Sprintf ("Verified the signature of the %s file and the fingerprints" , relaysManifestFilePath ))
93
77
} else {
94
- if goodSig {
95
- spinner .UpdateText (fmt .Sprintf ("Verified the signature of the %s file" , relaysManifestFilePath ))
96
- } else {
97
- pterm .Println ()
98
- pterm .Error .Println (fmt .Sprintf ("Failed to verify the signature of the %s file" , relaysManifestFilePath ))
99
- os .Exit (1 )
100
- }
78
+ pterm .Println ()
79
+ pterm .Error .Println (fmt .Sprintf ("Failed to verify the signature of the %s file and/or the fingerprints" , relaysManifestFilePath ))
80
+ os .Exit (1 )
101
81
}
102
82
103
83
// Compute the SHA512 hash of the compressed relay binary file
@@ -123,23 +103,6 @@ func VerifyRelayBinary(path string) {
123
103
// Search the manifest file for the hash
124
104
if strings .Contains (string (data ), sha512Hash ) {
125
105
spinner .UpdateText (fmt .Sprintf ("Verified the SHA512 hash of the %s file" , path ))
126
- pterm .Println ()
127
-
128
- // Prompt user if they want to continue with installation without verifying fingerprints
129
- if ! foundPrimaryKeyText || ! foundSubkeyText {
130
- pterm .Println ()
131
- spinner .Warning (fmt .Sprintf ("Warning: The signature of the %s file was valid but the fingerprints were not checked." , relaysManifestFilePath ))
132
-
133
- pterm .Println ()
134
-
135
- result , _ := prompt .Show ()
136
-
137
- if result == "no" {
138
- os .Exit (1 )
139
- }
140
- }
141
-
142
- pterm .Println ()
143
106
spinner .Success ("Relay binary verified" )
144
107
} else {
145
108
pterm .Println ()
0 commit comments