3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 18:52:41 +01:00

Merge pull request #623 from slingamn/issue622.1

fix #622
This commit is contained in:
Shivaram Lingamneni 2019-09-12 02:43:41 -07:00 committed by GitHub
commit f615809d03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,6 +39,13 @@ func getPassword() string {
return strings.TrimSpace(text)
}
func fileDoesNotExist(file string) bool {
if _, err := os.Stat(file); os.IsNotExist(err) {
return true
}
return false
}
// implements the `oragono mkcerts` command
func doMkcerts(configFile string, quiet bool) {
config, err := irc.LoadRawConfig(configFile)
@ -59,7 +66,7 @@ func doMkcerts(configFile string, quiet bool) {
if existingKey == conf.TLS.Key {
continue
} else {
log.Fatal("Conflicting TLS key files for", conf.TLS.Cert)
log.Fatal("Conflicting TLS key files for ", conf.TLS.Cert)
}
}
if !quiet {
@ -67,6 +74,9 @@ func doMkcerts(configFile string, quiet bool) {
}
host := config.Server.Name
cert, key := conf.TLS.Cert, conf.TLS.Key
if !(fileDoesNotExist(cert) && fileDoesNotExist(key)) {
log.Fatalf("Preexisting TLS cert and/or key files: %s %s", cert, key)
}
err := mkcerts.CreateCert("Oragono", host, cert, key)
if err == nil {
if !quiet {