You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by ka...@apache.org on 2022/11/14 08:13:25 UTC

[james-project] branch master updated: JAMES-3851 TLS host name verification should handle trailing dot

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

kao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
     new 46475b33fa JAMES-3851 TLS host name verification should handle trailing dot
46475b33fa is described below

commit 46475b33fa9e3e25837b33a00a3e0c25809bad05
Author: Karsten Otto <ka...@akquinet.de>
AuthorDate: Thu Nov 10 14:29:38 2022 +0100

    JAMES-3851 TLS host name verification should handle trailing dot
---
 .../mailets/remote/delivery/MailDelivrerToHost.java         | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrerToHost.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrerToHost.java
index e816d782c7..5580f079cc 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrerToHost.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrerToHost.java
@@ -252,14 +252,23 @@ public class MailDelivrerToHost {
 
     private void connect(HostAddress outgoingMailServer, SMTPTransport transport) throws MessagingException {
         if (configuration.getAuthUser() != null) {
-            transport.connect(outgoingMailServer.getHostName(), configuration.getAuthUser(), configuration.getAuthPass());
+            transport.connect(getHostName(outgoingMailServer), configuration.getAuthUser(), configuration.getAuthPass());
         } else if (configuration.isConnectByHostname()) {
-            transport.connect(outgoingMailServer.getHostName(), null, null);
+            transport.connect(getHostName(outgoingMailServer), null, null);
         } else {
             transport.connect(); // connect via IP address instead of host name
         }
     }
 
+    private String getHostName(HostAddress outgoingMailServer) {
+        String host = outgoingMailServer.getHostName();
+        if (host.length() > 0 && host.charAt(host.length() - 1) == '.') {
+            return host.substring(0, host.length() - 1);
+        } else {
+            return host;
+        }
+    }
+
     private MimeMessage adaptToTransport(MimeMessage message, SMTPTransport transport) throws MessagingException {
         if (shouldAdapt(transport)) {
             try {


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org