@@ -99,11 +99,15 @@ var webCmd = &cobra.Command{
99
99
100
100
if TLS && (tlsKey == "" || tlsCertificate == "" ) {
101
101
var err error
102
- cert , err = utils .GenerateTLSCertificate (commonName )
103
- if err != nil {
104
- return errors .New ("Error while generating certificate: " + err .Error ())
102
+ if commonName == "" {
103
+ cert , err = utils .GenerateTLSSelfSignedCertificate (commonName )
104
+ if err != nil {
105
+ return errors .New ("Error while generating certificate: " + err .Error ())
106
+ }
107
+ TLSConfig .Certificates = append (TLSConfig .Certificates , * cert )
108
+ } else {
109
+ TLSConfig , err = utils .GenerateTLSLetsencryptCertificate (commonName )
105
110
}
106
- TLSConfig .Certificates = append (TLSConfig .Certificates , * cert )
107
111
} else if (TLS || tlsKey != "" || tlsCertificate != "" ) && (! TLS || tlsKey == "" || tlsCertificate == "" ) {
108
112
return errors .New ("Tls, certificate and/or key arguments missing" )
109
113
@@ -189,7 +193,7 @@ func init() {
189
193
webCmd .Flags ().BoolVar (& promptPassword , "promptPassword" , false , "Prompt for for basic auth's password" )
190
194
191
195
webCmd .Flags ().BoolVar (& TLS , "tls" , false , "Enables HTTPS (for web and webdav)" )
192
- webCmd .Flags ().StringVarP (& commonName , "commonName" , "n" ,"" , "Common name to use in the certificat" )
196
+ webCmd .Flags ().StringVarP (& commonName , "commonName" , "n" , "" , "Common name to use in the certificat" )
193
197
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)" )
194
198
webCmd .Flags ().StringVarP (& tlsKey , "key" , "k" , "" , "HTTPS Key : openssl genrsa -out server.key 2048 (for web and webdav)" )
195
199
0 commit comments