appsmith icon indicating copy to clipboard operation
appsmith copied to clipboard

[Bug]: Appsmith shouldn't attempt to STARTTLS if TLS is disabled in the config.

Open AS-Laguna opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Description

When starting a server that has TLS disabled in the config, it will attempt STARTTLS anyway.

I expect the server to not try STARTTLS if TLS is disabled.

Steps To Reproduce

  1. Disable TLS in your instance config.
  2. Start your instance and watch the logs.
  3. Observer that STARTTLS is logged anyway.

Public Sample App

No response

Issue video log

No response

Version

1.9.7

Front logo Front conversations

AS-Laguna avatar Feb 22 '23 17:02 AS-Laguna

I think what could solve this is to try the following: In EnvManagerCEImpl.java around line 700 to move the line props.put("mail.smtp.starttls.enable", "true"); into the following if-else clause.

Properties props = mailSender.getJavaMailProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.timeout", 7000); // 7 seconds

if (StringUtils.hasLength(requestDTO.getUsername())) {
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.auth", "true");
    mailSender.setUsername(requestDTO.getUsername());
    mailSender.setPassword(requestDTO.getPassword());
} else {
    props.put("mail.smtp.starttls.enable", "false");
    props.put("mail.smtp.auth", "false");
}
props.put("mail.debug", "true");

This way starttls is only true when the TLS option is checked in the test mail form.

degude avatar May 11 '23 07:05 degude

@degude, indeed. Thanks for suggesting. We actually have a PR regarding that at #17952, but that was doing a little too much, which was causing problems in merging. I think I'll tone that PR back and only solve this one problem so it can finally go in.

I'll take this up. Thanks!

sharat87 avatar May 18 '23 00:05 sharat87

It works like a charm now, thank you guys ❤️

degude avatar Jun 03 '23 12:06 degude