Support configuring Mail SMTP SSL trust (#1886)

diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
index 32411a9..eddfa5d 100644
--- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
+++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
@@ -65,7 +65,8 @@
         boolean isDebug = Boolean.parseBoolean(props.getProperty(EmailPropertiesConstants.IS_DEBUG, EmailPropertiesConstants.DEFAULT_IS_DEBUG));
         String username = props.getProperty(EmailPropertiesConstants.USERNAME);
         String password = props.getProperty(EmailPropertiesConstants.PASSWORD);
-        session = Session.getDefaultInstance(createSessionProperties(host, port, isUseSSL, isDebug), getSessionAuthenticator(username, password));
+        String sslTrust = props.getProperty(EmailPropertiesConstants.SSL_TRUST);
+        session = Session.getDefaultInstance(createSessionProperties(host, port, isUseSSL, isDebug, sslTrust), getSessionAuthenticator(username, password));
         subject = props.getProperty(EmailPropertiesConstants.SUBJECT, EmailPropertiesConstants.DEFAULT_SUBJECT);
         from = props.getProperty(EmailPropertiesConstants.FROM);
         to = props.getProperty(EmailPropertiesConstants.TO);
@@ -73,7 +74,7 @@
         bcc = props.getProperty(EmailPropertiesConstants.BCC);
     }
     
-    private Properties createSessionProperties(final String host, final int port, final boolean isUseSSL, final boolean isDebug) {
+    private Properties createSessionProperties(final String host, final int port, final boolean isUseSSL, final boolean isDebug, final String sslTrust) {
         Properties result = new Properties();
         result.put("mail.smtp.host", host);
         result.put("mail.smtp.port", port);
@@ -83,6 +84,9 @@
         if (isUseSSL) {
             result.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
             result.setProperty("mail.smtp.socketFactory.fallback", Boolean.FALSE.toString());
+            if (!Strings.isNullOrEmpty(sslTrust)) {
+                result.setProperty("mail.smtp.ssl.trust", sslTrust);
+            }
         }
         return result;
     }
diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailPropertiesConstants.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailPropertiesConstants.java
index eff753b..fe93b3b 100644
--- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailPropertiesConstants.java
+++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailPropertiesConstants.java
@@ -32,6 +32,8 @@
     
     public static final String HOST = PREFIX + "host";
     
+    public static final String SSL_TRUST = PREFIX + "ssl.trust";
+    
     public static final String PORT = PREFIX + "port";
     
     public static final String USERNAME = PREFIX + "username";
diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidatorTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidatorTest.java
index e9d98bf..7bd2a1e 100644
--- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidatorTest.java
+++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidatorTest.java
@@ -38,6 +38,7 @@
     public void assertValidateWithNormal() {
         Properties properties = new Properties();
         properties.setProperty(EmailPropertiesConstants.HOST, "host");
+        properties.setProperty(EmailPropertiesConstants.SSL_TRUST, "*");
         properties.setProperty(EmailPropertiesConstants.PORT, "465");
         properties.setProperty(EmailPropertiesConstants.USERNAME, "username");
         properties.setProperty(EmailPropertiesConstants.PASSWORD, "password");
diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java
index 7ade63f..c4be29e 100644
--- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java
+++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java
@@ -105,6 +105,7 @@
     private Properties createConfigurationProperties() {
         Properties result = new Properties();
         result.setProperty(EmailPropertiesConstants.HOST, "localhost");
+        result.setProperty(EmailPropertiesConstants.SSL_TRUST, "*");
         result.setProperty(EmailPropertiesConstants.PORT, "465");
         result.setProperty(EmailPropertiesConstants.USERNAME, "user");
         result.setProperty(EmailPropertiesConstants.PASSWORD, "xxx");