github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/main/commands/all/verify.go (about) 1 package all 2 3 import ( 4 "os" 5 6 "github.com/v2fly/VSign/signerVerify" 7 8 "github.com/v2fly/v2ray-core/v5/main/commands/base" 9 ) 10 11 var cmdVerify = &base.Command{ 12 UsageLine: "{{.Exec}} verify [--sig=sig-file] file", 13 Short: "verify if a binary is officially signed", 14 Long: ` 15 Verify if a binary is officially signed. 16 17 Arguments: 18 19 -sig <signature_file> 20 The path to the signature file 21 `, 22 } 23 24 func init() { 25 cmdVerify.Run = executeVerify // break init loop 26 } 27 28 var verifySigFile = cmdVerify.Flag.String("sig", "", "Path to the signature file") 29 30 func executeVerify(cmd *base.Command, args []string) { 31 target := cmdVerify.Flag.Arg(0) 32 if target == "" { 33 base.Fatalf("empty file path.") 34 } 35 36 if *verifySigFile == "" { 37 base.Fatalf("empty signature path.") 38 } 39 40 sigReader, err := os.Open(os.ExpandEnv(*verifySigFile)) 41 if err != nil { 42 base.Fatalf("failed to open file %s: %s ", *verifySigFile, err) 43 } 44 45 files := cmdVerify.Flag.Args() 46 47 err = signerVerify.OutputAndJudge(signerVerify.CheckSignaturesV2Fly(sigReader, files)) 48 if err != nil { 49 base.Fatalf("file is not officially signed by V2Ray: %s", err) 50 } 51 }