ca

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CACmd = &cobra.Command{
	Use:   "ca",
	Short: "CA commands",
	Long:  `Manipulate CA`,
}
View Source
var CreateCACmd = &cobra.Command{
	Use:   "loadorcreate",
	Short: "Create a new CA and save in a secret",
	Long:  `Create a new CA and save in a secret`,
	Run: func(cmd *cobra.Command, args []string) {
		myca := new(pki.CA)
		myca.SetupCA()
		err := myca.NewCA()
		if err != nil {
			log.Fatal(err)
		}
		if cafile != "" && cakeyfile != "" {
			err = myca.SaveToFile(cafile, cakeyfile)
			if err != nil {
				panic(err.Error())
			}
		} else if cafile != "" || cakeyfile != "" {
			if err != nil {
				panic(errors.New("please use cafile and cakeyfile arguments"))
			}
		} else {
			if name == "" {
				name = utils.GetEnv("SECRETNAME", "micropki-ca")
			}
			namespace, err := vars.ValidateNamespace(namespace)
			if err != nil {
				panic(err.Error())
			}

			err = myca.LoadFromSecret(name, namespace)
			if err != nil {
				log.Fatal("Secret can't be loaded")
				log.Fatal(err.Error())
				err = myca.NewCA()
				if err != nil {
					panic(err.Error())
				}
				err = myca.SaveToSecret(name, namespace)
				if err != nil {
					panic(err.Error())
				}
			}
		}
	},
}

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