Ejemplo n.º 1
0
func runLang(cmd *flagplus.Subcommand, args []string) {
	if *CACert == "" {
		log.Fatal("Missing required parameter in flag `-ca-cert`")
	}
	if (*CACert)[0] != '.' && (*CACert)[0] != os.PathSeparator {
		*CACert = filepath.Join(Dir.Cert, *CACert+EXT_CERT)
	}

	serverFile := ""
	clientFile := ""
	if *IsGo {
		serverFile = FILE_SERVER_GO
		clientFile = FILE_CLIENT_GO
	} else {
		log.Print("Missing required flag -- `-go`")
		cmd.Usage()
	}

	if *ServerCert != "" {
		if _, err := os.Stat(serverFile); !os.IsNotExist(err) {
			log.Fatalf("File already exists: %q", serverFile)
		}
	}
	if *IsClient {
		if _, err := os.Stat(clientFile); !os.IsNotExist(err) {
			log.Fatalf("File already exists: %q", clientFile)
		}
	}

	Cert2Lang()
}
Ejemplo n.º 2
0
func runInfo(cmd *flagplus.Subcommand, args []string) {
	if len(args) != 1 {
		log.Print("Missing required argument: FILE")
		cmd.Usage()
	}

	*IsCert = true
	file := getAbsPaths(false, args)
	run := false

	if *IsEndDate {
		fmt.Print(InfoEndDate(file[0]))
		run = true
	}
	if *IsHash {
		fmt.Print(InfoHash(file[0]))
		run = true
	}
	if *IsIssuer {
		fmt.Print(InfoIssuer(file[0]))
		run = true
	}
	if *IsName {
		fmt.Print(InfoName(file[0]))
		run = true
	}
	if !run {
		fmt.Print(InfoFull(file[0]))
	}
}
Ejemplo n.º 3
0
func runSign(cmd *flagplus.Subcommand, args []string) {
	if len(args) != 1 {
		log.Print("Missing required argument: NAME")
		cmd.Usage()
	}
	setCertPath(args[0])

	SignReq()
}
Ejemplo n.º 4
0
func runCat(cmd *flagplus.Subcommand, args []string) {
	if len(args) != 1 {
		log.Print("Missing required argument: FILE")
		cmd.Usage()
	}

	file := getAbsPaths(false, args)

	if *IsCert {
		fmt.Print(InfoCert(file[0]))
	} else if *IsRequest {
		fmt.Print(InfoRequest(file[0]))
	} else if *IsKey {
		fmt.Print(InfoKey(file[0]))
	} else {
		log.Print("Missing required flag")
		cmd.Usage()
	}
}