Exemple #1
0
func newCertAction(c *cli.Context) {

	if len(c.Args()) != 1 {
		fmt.Fprintln(os.Stderr, "cert file must be provided.")
		os.Exit(1)
	}

	certFileName := c.Args()[0]
	years := c.Int("years")
	bits := c.Int("key-bits")

	if c.IsSet("passphrase") {

	}

	ips := c.String("ips")
	ipArray := strings.Split(ips, ",")

	certFile := certFileName + crtSuffix
	keyFile := certFileName + "-key" + crtSuffix
	caFile := caPrefix + crtSuffix
	caKeyFile := caKeyPrefix + crtSuffix
	org := c.String("organization")
	commonName := c.String("common-name")

	err := utils.GenerateCert(ipArray, d.Path(certFile), d.Path(keyFile), d.Path(caFile), d.Path(caKeyFile), org, commonName, years, bits)
	if err != nil {
		fmt.Fprintln(os.Stderr, "Create Servcer cert error:", err)
		os.Exit(1)
	} else {
		fmt.Println("Create server/key complete")
	}

}
Exemple #2
0
func initAction(c *cli.Context) {

	err := utils.GenerateCACertificate(d.Path(caPrefix+crtSuffix), d.Path(caKeyPrefix+crtSuffix), c.String("organization"), c.Int("years"), c.Int("key-bits"))
	//	key, err := pkix.CreateRSAKey(c.Int("key-bits"))
	if err != nil {
		fmt.Fprintln(os.Stderr, "Create CA cert error:", err)
		os.Exit(1)
	} else {
		fmt.Println("Created ca/key complete")
	}
}