Skip to content

Commit

Permalink
Option to add choose the CommonName when the certificat is generated
Browse files Browse the repository at this point in the history
  • Loading branch information
nodauf committed Aug 31, 2023
1 parent 7ea46d4 commit a9bb335
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ var Verbose bool

// cert contains certificate and private key
var cert *tls.Certificate
var commonName string

var promptPassword bool
var cwd string
Expand All @@ -84,6 +85,7 @@ var webCmd = &cobra.Command{
TLS = viper.GetBool("TLS")
tlsCertificate = viper.GetString("Certificate")
tlsKey = viper.GetString("Key")
commonName = viper.GetString("CommonName")
DisableListing = viper.GetBool("DisableListing")
Gzip = viper.GetBool("Gzip")
Oneliners = viper.GetBool("Oneliners")
Expand All @@ -97,7 +99,7 @@ var webCmd = &cobra.Command{

if TLS && (tlsKey == "" || tlsCertificate == "") {
var err error
cert, err = utils.GenerateTLSCertificate("")
cert, err = utils.GenerateTLSCertificate(commonName)
if err != nil {
return errors.New("Error while generating certificate: " + err.Error())
}
Expand Down Expand Up @@ -187,6 +189,7 @@ func init() {
webCmd.Flags().BoolVar(&promptPassword, "promptPassword", false, "Prompt for for basic auth's password")

webCmd.Flags().BoolVar(&TLS, "tls", false, "Enables HTTPS (for web and webdav)")
webCmd.Flags().StringVarP(&commonName, "commonName", "n","", "Common name to use in the certificat")
webCmd.Flags().StringVarP(&tlsCertificate, "certificate", "c", "", "HTTPS certificate : openssl req -new -x509 -sha256 -key server.key -out server.crt -days 365 (for web and webdav)")
webCmd.Flags().StringVarP(&tlsKey, "key", "k", "", "HTTPS Key : openssl genrsa -out server.key 2048 (for web and webdav)")

Expand Down

0 comments on commit a9bb335

Please sign in to comment.