浏览代码

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

Someone 1 年之前
父节点
当前提交
923fa48a97
共有 4 个文件被更改,包括 14 次插入2 次删除
  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."
   "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_Password: config.EmailConfig.Password,
           Email_From: config.EmailConfig.From,
           Email_From: config.EmailConfig.From,
           Email_UseTLS : config.EmailConfig.UseTLS,
           Email_UseTLS : config.EmailConfig.UseTLS,
+          Email_AllowInsecureTLS : config.EmailConfig.AllowInsecureTLS,
 
 
           SkipPruneNetwork: config.DockerConfig.SkipPruneNetwork,
           SkipPruneNetwork: config.DockerConfig.SkipPruneNetwork,
           DefaultDataPath: config.DockerConfig.DefaultDataPath || "/usr",
           DefaultDataPath: config.DockerConfig.DefaultDataPath || "/usr",
@@ -169,6 +170,7 @@ const ConfigManagement = () => {
               Password: values.Email_Password,
               Password: values.Email_Password,
               From: values.Email_From,
               From: values.Email_From,
               UseTLS: values.Email_UseTLS,
               UseTLS: values.Email_UseTLS,
+              AllowInsecureTLS: values.Email_AllowInsecureTLS,
             },
             },
             DockerConfig: {
             DockerConfig: {
               ...config.DockerConfig,
               ...config.DockerConfig,
@@ -519,6 +521,15 @@ const ConfigManagement = () => {
                       formik={formik}
                       formik={formik}
                       helperText="SMTP Uses TLS"
                       helperText="SMTP Uses TLS"
                     />
                     />
+
+                    {formik.values.Email_UseTLS && (
+                      <CosmosCheckbox
+                        label="Allow Insecure TLS"
+                        name="Email_AllowInsecureTLS"
+                        formik={formik}
+                        helperText="Allow self-signed certificate"
+                      />
+                    )}
                   </>)}
                   </>)}
                 </Stack>
                 </Stack>
               </MainCard>
               </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)
 	auth := smtp.PlainAuth("", config.EmailConfig.Username, config.EmailConfig.Password, config.EmailConfig.Host)
 
 
 	tlsConfig := &tls.Config{
 	tlsConfig := &tls.Config{
-		InsecureSkipVerify: false,
+		InsecureSkipVerify: config.EmailConfig.AllowInsecureTLS,
 		ServerName:         config.EmailConfig.Host,
 		ServerName:         config.EmailConfig.Host,
 	}
 	}
 
 

+ 1 - 0
src/utils/types.go

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