Skip to content

Commit

Permalink
Merge pull request #69 from flownative/feature/multiple-ssl-hosts
Browse files Browse the repository at this point in the history
Allow multiple hosts for HTTPS setup
  • Loading branch information
kdambekalns authored Apr 25, 2024
2 parents 82d7fab + fadce02 commit 27c1937
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/beach/cmd/setup-https.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/flownative/localbeach/pkg/path"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"strings"
)

var host string
Expand All @@ -35,7 +36,7 @@ var setupHttpsCmd = &cobra.Command{
}

func init() {
setupHttpsCmd.Flags().StringVar(&host, "host", "*.localbeach.net", "Host to use for the certificate.")
setupHttpsCmd.Flags().StringVar(&host, "host", "*.localbeach.net", "Host to use for the certificate. Multiple can be given comma-separated.")
rootCmd.AddCommand(setupHttpsCmd)
}

Expand All @@ -50,7 +51,10 @@ func handleSetupHttpsRun(cmd *cobra.Command, args []string) {
return
}

commandArgs = []string{"-cert-file", path.Certificates + "default.crt", "-key-file", path.Certificates + "default.key", host}
commandArgs = []string{"-cert-file", path.Certificates + "default.crt", "-key-file", path.Certificates + "default.key"}
for _, hostname := range strings.Split(host, ",") {
commandArgs = append(commandArgs, strings.Trim(hostname, " "))
}
err = exec.RunInteractiveCommand("mkcert", commandArgs)
if err != nil {
log.Error(err)
Expand Down

0 comments on commit 27c1937

Please sign in to comment.