From 9b336299ea0b01d9ff1afd6b5cc7f9d4356113d2 Mon Sep 17 00:00:00 2001 From: royroyee Date: Sat, 15 Jun 2024 09:00:25 +0900 Subject: [PATCH] Fix csr input validation --- cmd/csr/csr_create.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/csr/csr_create.go b/cmd/csr/csr_create.go index ae25762..29977be 100644 --- a/cmd/csr/csr_create.go +++ b/cmd/csr/csr_create.go @@ -75,9 +75,13 @@ func promptForCert() (certApi.SignRequest, cert.CertificatePath) { var signRequest certApi.SignRequest var certPath cert.CertificatePath - signRequest.DomainList = utils.PromptForRequiredListInput("domain list (e.g., domain1.com, domain2.com): ") - signRequest.IpList = utils.PromptForRequiredListInput("ip list (e.g., 192.168.1.1, 10.0.0.1): ") - signRequest.ValidDays = utils.PromptForInput("valid days: ") + signRequest.DomainList = utils.PromptForListInput("domain list (e.g., domain1.com, domain2.com): ") + signRequest.IpList = utils.PromptForListInput("ip list (e.g., 192.168.1.1, 10.0.0.1): ") + if len(signRequest.DomainList) == 0 && len(signRequest.IpList) == 0 { + utils.CliError("You must enter at least a domain list or an IP list.") + } + + signRequest.ValidDays = utils.PromptForRequiredInput("valid days: ") domainName := signRequest.DomainList[0] defaultKeyPath := fmt.Sprintf("%s/%s.key", defaultPrivateKeyDir, domainName)