diff --git a/client/src/pages/home/index.jsx b/client/src/pages/home/index.jsx index 29faac4..c48cafb 100644 --- a/client/src/pages/home/index.jsx +++ b/client/src/pages/home/index.jsx @@ -226,6 +226,15 @@ const HomePage = () => { )} + {coStatus && coStatus.LetsEncryptErrors && coStatus.LetsEncryptErrors.length > 0 && ( + + There are errors with your Let's Encrypt configuration or one of your routes, please fix them as soon as possible.: + {coStatus.LetsEncryptErrors.map((err) => { + return
- {err}
+ })} +
+ )} + {coStatus && coStatus.newVersionAvailable && ( A new version of Cosmos is available! Please update to the latest version to get the latest features and bug fixes. diff --git a/package.json b/package.json index c6f8a98..daaa005 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cosmos-server", - "version": "0.9.0-unstable6", + "version": "0.9.0-unstable7", "description": "", "main": "test-server.js", "bugs": { diff --git a/src/status.go b/src/status.go index 43373ad..f819b0e 100644 --- a/src/status.go +++ b/src/status.go @@ -61,6 +61,7 @@ func StatusRoute(w http.ResponseWriter, req *http.Request) { "hostname": utils.GetMainConfig().HTTPConfig.Hostname, "CPU": runtime.GOARCH, "AVX": cpu.X86.HasAVX, + "LetsEncryptErrors": utils.LetsEncryptErrors, }, }) } else { diff --git a/src/utils/certificates.go b/src/utils/certificates.go index fbac658..9ea6dd0 100644 --- a/src/utils/certificates.go +++ b/src/utils/certificates.go @@ -141,10 +141,12 @@ func (u *CertUser) GetPrivateKey() crypto.PrivateKey { func DoLetsEncrypt() (string, string) { config := GetMainConfig() + LetsEncryptErrors = []string{} privateKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { Error("LETSENCRYPT_ECDSA", err) + LetsEncryptErrors = append(LetsEncryptErrors, err.Error()) return "", "" } @@ -166,6 +168,7 @@ func DoLetsEncrypt() (string, string) { client, err := lego.NewClient(certConfig) if err != nil { Error("LETSENCRYPT_NEW", err) + LetsEncryptErrors = append(LetsEncryptErrors, err.Error()) return "", "" } @@ -173,6 +176,7 @@ func DoLetsEncrypt() (string, string) { provider, err := dns.NewDNSChallengeProviderByName(config.HTTPConfig.DNSChallengeProvider) if err != nil { Error("LETSENCRYPT_DNS", err) + LetsEncryptErrors = append(LetsEncryptErrors, err.Error()) return "", "" } @@ -182,12 +186,14 @@ func DoLetsEncrypt() (string, string) { err = client.Challenge.SetHTTP01Provider(http01.NewProviderServer("", config.HTTPConfig.HTTPPort)) if err != nil { Error("LETSENCRYPT_HTTP01", err) + LetsEncryptErrors = append(LetsEncryptErrors, err.Error()) return "", "" } err = client.Challenge.SetTLSALPN01Provider(tlsalpn01.NewProviderServer("", config.HTTPConfig.HTTPSPort)) if err != nil { Error("LETSENCRYPT_TLS01", err) + LetsEncryptErrors = append(LetsEncryptErrors, err.Error()) return "", "" } @@ -195,6 +201,7 @@ func DoLetsEncrypt() (string, string) { reg, err := client.Registration.Register(registration.RegisterOptions{TermsOfServiceAgreed: true}) if err != nil { Error("LETSENCRYPT_REGISTER", err) + LetsEncryptErrors = append(LetsEncryptErrors, err.Error()) return "", "" } myUser.Registration = reg @@ -206,6 +213,7 @@ func DoLetsEncrypt() (string, string) { certificates, err := client.Certificate.Obtain(request) if err != nil { Error("LETSENCRYPT_OBTAIN", err) + LetsEncryptErrors = append(LetsEncryptErrors, err.Error()) return "", "" } diff --git a/src/utils/utils.go b/src/utils/utils.go index 11b2287..73d7a2e 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -33,6 +33,8 @@ var UpdateAvailable = map[string]bool{} var RestartHTTPServer func() +var LetsEncryptErrors = []string{} + var DefaultConfig = Config{ LoggingLevel: "INFO", NewInstall: true,