Browse Source

[release] v0.5.4 - Add DNS challenge to installer

Yann Stepienik 2 years ago
parent
commit
5fb4ce9d99
4 changed files with 32 additions and 4 deletions
  1. 24 2
      client/src/pages/newInstall/newInstall.jsx
  2. 1 1
      package.json
  3. 2 0
      src/newInstall.go
  4. 5 1
      src/utils/utils.go

+ 24 - 2
client/src/pages/newInstall/newInstall.jsx

@@ -226,6 +226,7 @@ const NewInstall = () => {
                 initialValues={{
                     HTTPSCertificateMode: "LETSENCRYPT",
                     UseWildcardCertificate: false,
+                    DNSChallengeProvider: '',
                 }}
                 validationSchema={Yup.object().shape({
                         SSLEmail: Yup.string().when('HTTPSCertificateMode', {
@@ -258,6 +259,7 @@ const NewInstall = () => {
                             TLSKey: values.HTTPSCertificateMode === "PROVIDED" ? values.TLSKey : '',
                             TLSCert: values.HTTPSCertificateMode === "PROVIDED" ? values.TLSCert : '',
                             Hostname: values.Hostname,
+                            DNSChallengeProvider: values.DNSChallengeProvider,
                         });
                         if(res.status == "OK") {
                             setStatus({ success: true });
@@ -287,7 +289,8 @@ const NewInstall = () => {
                             <>
                             <Alert severity="warning">
                                 If you are using Cloudflare, make sure the DNS record is <strong>NOT</strong> set to <b>Proxied</b> (you should not see the orange cloud but a grey one).
-                                Otherwise Cloudflare will not allow Let's Encrypt to verify your domain.
+                                Otherwise Cloudflare will not allow Let's Encrypt to verify your domain. <br />
+                                Alternatively, you can also use the DNS challenge.
                             </Alert>
                             <CosmosInputText
                                 name="SSLEmail"
@@ -295,6 +298,19 @@ const NewInstall = () => {
                                 placeholder={"email@domain.com"}
                                 formik={formik}
                             />
+                            {formik.values.DNSChallengeProvider && formik.values.DNSChallengeProvider != '' && (
+                                <Alert severity="info">
+                                    You have enabled the DNS challenge. Make sure you have set the environment variables for your DNS provider.
+                                    You can enable it now, but make sure you have set up your API tokens accordingly before attempting to access 
+                                    Cosmos after this installer. See doc here: <a target="_blank" href="https://go-acme.github.io/lego/dns/">https://go-acme.github.io/lego/dns/</a>
+                                </Alert>
+                            )}
+                            <CosmosInputText
+                                label={"DNS Provider (only set if you want to use the DNS challenge)"}
+                                name="DNSChallengeProvider"
+                                placeholder={"provider"}
+                                formik={formik}
+                            />
                             </>
                         )}
                         {formik.values.HTTPSCertificateMode === "PROVIDED" && (
@@ -323,9 +339,15 @@ const NewInstall = () => {
                             formik={formik}
                         />
 
+                        {formik.values.HTTPSCertificateMode === "LETSENCRYPT" && formik.values.UseWildcardCertificate && (!formik.values.DNSChallengeProvider || formik.values.DNSChallengeProvider == '') && (
+                            <Alert severity="error">
+                                You have enabled wildcard certificates with Let's Encrypt. This only works if you use the DNS challenge!
+                                Please edit the DNS Provider text input.
+                            </Alert>
+                        )}
                         
                         <CosmosCheckbox
-                            label={"Use Wildcard Certificate for *." + formik.values.Hostname}
+                            label={"Use Wildcard Certificate for *." + (formik.values.Hostname ||  "")}
                             name="UseWildcardCertificate"
                             formik={formik}
                         />

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "cosmos-server",
-  "version": "0.5.3",
+  "version": "0.5.4",
   "description": "",
   "main": "test-server.js",
   "bugs": {

+ 2 - 0
src/newInstall.go

@@ -33,6 +33,7 @@ type NewInstallJSON struct {
 	Step string `json:"step"`
 	SSLEmail string `json:"sslEmail",validate:"omitempty,email"`
 	UseWildcardCertificate bool `json:"useWildcardCertificate",validate:"omitempty"`
+	DNSChallengeProvider string `json:"dnsChallengeProvider",validate:"omitempty"`
 }
 
 type AdminJSON struct {
@@ -108,6 +109,7 @@ func NewInstallRoute(w http.ResponseWriter, req *http.Request) {
 			newConfig.HTTPConfig.HTTPSCertificateMode = request.HTTPSCertificateMode
 			newConfig.HTTPConfig.SSLEmail = request.SSLEmail
 			newConfig.HTTPConfig.UseWildcardCertificate = request.UseWildcardCertificate
+			newConfig.HTTPConfig.DNSChallengeProvider = request.DNSChallengeProvider
 			newConfig.HTTPConfig.TLSCert = request.TLSCert
 			newConfig.HTTPConfig.TLSKey = request.TLSKey
 

+ 5 - 1
src/utils/utils.go

@@ -169,7 +169,7 @@ func ReadConfigFromFile() Config {
 	return config
 }
 
-func LoadBaseMainConfig(config Config){
+func LoadBaseMainConfig(config Config) {
 	BaseMainConfig = config
 	MainConfig = config
 
@@ -211,6 +211,10 @@ func LoadBaseMainConfig(config Config){
 	if os.Getenv("COSMOS_SERVER_COUNTRY") != "" {
 		MainConfig.ServerCountry = os.Getenv("COSMOS_SERVER_COUNTRY")
 	}
+	
+	// if BaseMainConfig.NewInstall {
+	// 	MainConfig.HTTPConfig.HTTPSCertificateMode = "DISABLED"
+	// }
 }
 
 func GetMainConfig() Config {