verify

package
v2.0.0-...-6831f71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VerifyCmd = &cobra.Command{
	Use:   "verify",
	Short: "Verify the yaml",
	Long:  `Verify the yaml. Takes yaml file, ca as args`,
	Run: func(cmd *cobra.Command, args []string) {

		if ca == "" {
			log.Error(errors.New("ca not provided"), "ca not provided")
			os.Exit(1)
		}

		var file io.ReadCloser
		var err error
		if signer.IsInputFromPipe() {
			file = os.Stdin
		} else {
			file, err = signer.OpenInputFile(f)
			if err != nil {
				log.Error(err, "Could not open input file")
				os.Exit(1)
			}
		}

		uobjs, err := signer.Decode(file)
		file.Close()
		if err != nil {
			log.Error(err, "Could not Decode input yaml contents")
			os.Exit(1)
		}

		caCert, err := signer.CertificateFromPemFile(ca)
		if err != nil {
			log.Error(err, "Could not retrieve ca certificate")
			os.Exit(1)
		}

		err = signer.VerifySignatureArray(uobjs, caCert)
		if err != nil {
			fmt.Printf("yaml failed verification")
			log.Error(err, "yaml failed verification")
			os.Exit(1)
		}

		os.Exit(0)
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL