You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2021/05/07 14:30:16 UTC

[sling-org-apache-sling-committer-cli] branch master updated: SLING-10360 - The CLI tool cannot send emails via mail-relay.apache.org any more

This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-committer-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new 4845139  SLING-10360 - The CLI tool cannot send emails via mail-relay.apache.org any more
4845139 is described below

commit 4845139eada3e84c7db9054348965b8da0dc687a
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Fri May 7 16:28:38 2021 +0200

    SLING-10360 - The CLI tool cannot send emails via mail-relay.apache.org any more
    
    * add all supported protocols of the default SSL context
---
 .../java/org/apache/sling/cli/impl/mail/Mailer.java    | 18 +++++++++++++-----
 .../sling/cli/impl/release/TallyVotesCommandTest.java  |  3 ++-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sling/cli/impl/mail/Mailer.java b/src/main/java/org/apache/sling/cli/impl/mail/Mailer.java
index 58a873b..1a3d2ee 100644
--- a/src/main/java/org/apache/sling/cli/impl/mail/Mailer.java
+++ b/src/main/java/org/apache/sling/cli/impl/mail/Mailer.java
@@ -26,6 +26,7 @@ import javax.mail.MessagingException;
 import javax.mail.Session;
 import javax.mail.Transport;
 import javax.mail.internet.MimeMessage;
+import javax.net.ssl.SSLContext;
 
 import org.apache.sling.cli.impl.Credentials;
 import org.apache.sling.cli.impl.CredentialsService;
@@ -43,11 +44,18 @@ public class Mailer {
 
     private static final Properties SMTP_PROPERTIES = new Properties();
     static {
-        SMTP_PROPERTIES.put("mail.smtp.host", "mail-relay.apache.org");
-        SMTP_PROPERTIES.put("mail.smtp.port", "465");
-        SMTP_PROPERTIES.put("mail.smtp.auth", "true");
-        SMTP_PROPERTIES.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
-        SMTP_PROPERTIES.put("mail.smtp.socketFactory.fallback", "false");
+        try {
+            SMTP_PROPERTIES.put("mail.smtp.host", "mail-relay.apache.org");
+            SMTP_PROPERTIES.put("mail.smtp.port", "465");
+            SMTP_PROPERTIES.put("mail.smtp.auth", "true");
+            SMTP_PROPERTIES.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
+            SMTP_PROPERTIES.put("mail.smtp.socketFactory.fallback", "false");
+            SMTP_PROPERTIES.put("mail.smtp.ssl.protocols",
+                    String.join(" ", SSLContext.getDefault().getSupportedSSLParameters().getProtocols())
+            );
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
     }
 
     @Reference
diff --git a/src/test/java/org/apache/sling/cli/impl/release/TallyVotesCommandTest.java b/src/test/java/org/apache/sling/cli/impl/release/TallyVotesCommandTest.java
index ea07a04..c96835c 100644
--- a/src/test/java/org/apache/sling/cli/impl/release/TallyVotesCommandTest.java
+++ b/src/test/java/org/apache/sling/cli/impl/release/TallyVotesCommandTest.java
@@ -65,7 +65,8 @@ import static org.powermock.api.mockito.PowerMockito.mockStatic;
                          // https://github.com/powermock/powermock/issues/864
                          "com.sun.org.apache.xerces.*",
                          "javax.xml.*",
-                         "org.w3c.dom.*"
+                         "org.w3c.dom.*",
+                         "javax.net.ssl.*"
                  })
 public class TallyVotesCommandTest {