Browse Source

[skip ci] Allow Insecure TLS like self-signed certificate for SMTP server (#118)

Someone 1 year ago
parent
commit
923fa48a97
4 changed files with 14 additions and 2 deletions
  1. 1 1
      .clabot
  2. 11 0
      client/src/pages/config/users/configman.jsx
  3. 1 1
      src/utils/emails.go
  4. 1 0
      src/utils/types.go

+ 1 - 1
.clabot

@@ -1,4 +1,4 @@
 {
-  "contributors": ["azukaar", "jwr1", "Jogai"],
+  "contributors": ["azukaar", "jwr1", "Jogai", "InterN0te"],
   "message": "We require contributors to sign our [Contributor License Agreement](https://github.com/azukaar/Cosmos-Server/blob/master/cla.md). In order for us to review and merge your code, add yourself to the .clabot file as contributor, as a way of signing the CLA."
 }

+ 11 - 0
client/src/pages/config/users/configman.jsx

@@ -115,6 +115,7 @@ const ConfigManagement = () => {
           Email_Password: config.EmailConfig.Password,
           Email_From: config.EmailConfig.From,
           Email_UseTLS : config.EmailConfig.UseTLS,
+          Email_AllowInsecureTLS : config.EmailConfig.AllowInsecureTLS,
 
           SkipPruneNetwork: config.DockerConfig.SkipPruneNetwork,
           DefaultDataPath: config.DockerConfig.DefaultDataPath || "/usr",
@@ -169,6 +170,7 @@ const ConfigManagement = () => {
               Password: values.Email_Password,
               From: values.Email_From,
               UseTLS: values.Email_UseTLS,
+              AllowInsecureTLS: values.Email_AllowInsecureTLS,
             },
             DockerConfig: {
               ...config.DockerConfig,
@@ -519,6 +521,15 @@ const ConfigManagement = () => {
                       formik={formik}
                       helperText="SMTP Uses TLS"
                     />
+
+                    {formik.values.Email_UseTLS && (
+                      <CosmosCheckbox
+                        label="Allow Insecure TLS"
+                        name="Email_AllowInsecureTLS"
+                        formik={formik}
+                        helperText="Allow self-signed certificate"
+                      />
+                    )}
                   </>)}
                 </Stack>
               </MainCard>

+ 1 - 1
src/utils/emails.go

@@ -88,7 +88,7 @@ func SendEmail(recipients []string, subject string, body string) error {
 	auth := smtp.PlainAuth("", config.EmailConfig.Username, config.EmailConfig.Password, config.EmailConfig.Host)
 
 	tlsConfig := &tls.Config{
-		InsecureSkipVerify: false,
+		InsecureSkipVerify: config.EmailConfig.AllowInsecureTLS,
 		ServerName:         config.EmailConfig.Host,
 	}
 

+ 1 - 0
src/utils/types.go

@@ -198,6 +198,7 @@ type EmailConfig struct {
 	Password   string
 	From       string
 	UseTLS		 bool
+	AllowInsecureTLS		 bool
 }
 
 type OpenIDClient struct {