Skip to content

Enhancement: manual IP specification during server:ca:install command #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
10 changes: 8 additions & 2 deletions commands/local_server_ca_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package commands
import (
"os"
"path/filepath"
"strings"

"github.com/pkg/errors"
"github.com/symfony-cli/cert"
Expand All @@ -38,6 +39,7 @@ var localServerCAInstallCmd = &console.Command{
Flags: []console.Flag{
&console.BoolFlag{Name: "renew", Usage: "Force generating a new CA"},
&console.BoolFlag{Name: "force", Aliases: []string{"f"}, Usage: "Force reinstalling current CA"},
&console.StringFlag{Name: "ips", Usage: "Comma-separated list of IPs for the certificate", DefaultText: "localhost,127.0.0.1,::1"},
},
Action: func(c *console.Context) error {
ui := terminal.SymfonyStyle(terminal.Stdout, terminal.Stdin)
Expand Down Expand Up @@ -73,9 +75,13 @@ var localServerCAInstallCmd = &console.Command{
p12 := filepath.Join(homeDir, "certs", "default.p12")
if _, err := os.Stat(p12); os.IsNotExist(err) {
terminal.Println("Generating a default certificate for HTTPS support")
err := ca.MakeCert(p12, []string{"localhost", "127.0.0.1", "::1"})
if c.String("ips") != "" {
err = ca.MakeCert(p12, strings.Split(c.String("ips"), ","))
} else {
err = ca.MakeCert(p12, []string{"localhost", "127.0.0.1", "::1"})
}
if err != nil {
return errors.Wrap(err, "failed to generate a default certificate for localhost")
return errors.Wrap(err, "failed to generate a default certificate")
}
}

Expand Down
Loading