-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add config support for 'verifyingServerIdentity' with SMTP, also: since Angus 1.1.0 (8.6.0) server identity checks are on by default and can be countered by mailerBuilder.verifyingServerIdentity(false)
#495
Comments
This is unexpected. 8.6 is the switch to Angus Mail, which is the successor to Jakarta Mail. Angus splits up the interface from the implementation, effectively providing a reference implementation. However, supposedly, they haven't changed anything. I'll have to dig through the Angus changes to see what they did. Just for my sake, can you please, right after it failed, try with a 8.5 version you think should be working and see if that is the case? I just want to rule out a server side issue. |
Of course, I would not write something without being sure of it. I switch to version 8.5.1 (or 8.4) - everything works right away. I return 8.6.0 or 8.6.3 - everything immediately crashes with the error that I published. If you need any more information, I will be happy to help (as far as my competence is sufficient). |
What happens if you ditch the line TransportStrategy.SMTP.setOpportunisticTLS(false); |
I tried dropping the .withProperty("mail.smtp.ssl.enable", false) line and ran 5 tests:
None of the options gave a positive result. Then I tried disabling opportunistic TLS and setting the SMTP strategy - it worked. Working option:
|
It seems this is the appropriate way of connecting to the server, then. Classically secured, I would say. Probably privately managed? Or within demilitarized zone? Or do you disagree with this connection configuration? I generally discourage using custom properties, since that is what causes these kind of issues when a library version changes. Better depend on one of the transport strategies instead. |
This solved my problem and this option suits me. Thanks for your work! |
@bbottema Please check this: Angus Mail changelog. // com.sun.mail.util.SocketFetcher#configureSSLSocket
boolean idCheck = PropUtil.getBooleanProperty(props, prefix + ".ssl.checkserveridentity", false);
// org.eclipse.angus.mail.util.SocketFetcher#configureSSLSocket
boolean idCheck = PropUtil.getBooleanProperty(props, prefix + ".ssl.checkserveridentity", true); The difference cause Simple Java Mail can not connect to server with invalid certificates even with TransportStrategy.SMTP set. |
Angus 1.1.0 was released in December 30, 2022. We switched to Angus on Jan 17, 2024 with the release of 8.6.0.
Correction: only when TransportStrategy.SMTP is set. I just checked the code and we always explicitly configure *.ssl.checkserveridentity for all transport strategies, except SMTP. // MailerImpl.java
static private void configureServerIdentityVerification(@NotNull final Session session, @NotNull final OperationalConfig operationalConfig, @Nullable final TransportStrategy transportStrategy) {
if (transportStrategy != null && transportStrategy != TransportStrategy.SMTP) {
session.getProperties().setProperty(transportStrategy.propertyNameCheckServerIdentity(),
Boolean.toString(operationalConfig.isVerifyingServerIdentity()));
}
} As for why we don't set this for SMTP, I'm not sure: // TransportStrategy.SMTP
/**
* Always throws an exception, as this property is not relevant for plain SMTP.
*/
@Override
public String propertyNameCheckServerIdentity() {
throw new IllegalStateException("This property is not relevant for plain SMTP");
} I'm not entirely sure yet, but I think it's because of the opportunisticTLS which tries to upgrade the connection, in which case "*.ssl.checkserveridentity" becomes relevant again and that's why it fails for @narpetri unless opportunisticTLS is disabled manyally... I think. @ztyzbb |
…s as well, as is it still relevant for opportunistic TLS upgrades.
mailerBuilder.verifyingServerIdentity(false)
mailerBuilder.verifyingServerIdentity(false)
mailerBuilder.verifyingServerIdentity(false)
So, @narpetri, you can already revert the workaround of And @ztyzbb, thanks you so much for bringing this to my attention! |
@bbottema From web site and javadoc, when use |
To be clear: Simple Java Mail already has had this feature turned on for all transport strategies except SMTP. Due to historical reasons, for SMTP this feature was not enabled because it was not relevant until opportunistic TLS was implemented for #105. Now with the switch to Angus, for SMTP too, this feature is now enabled by default. @ztyzbb, I understand this breaks backwards compatibility, but I think it's the right choice. If you want degraded security on the server, that's totally up to you and you can do so with I already documented this in the RELEASE notes, but I realize I didn't update the documentation on the website. I will also update the JavaDoc. Thank you for reminding me. (edit: I have now updated documentation on these issues). |
Yeah, you are right, verify the server identity by default is better. |
Starting from version 8.6.0 everything stopped working.
My config (Kotlin):
When trying to connect I started getting this error:
Before this everything worked without errors. I deliberately replaced the IP address with zeros - that’s my real address.
What has changed with the 8.6.0 release, and what configurations need to be changed to continue to benefit from the latest updates and improvements?
Thank you!
The text was updated successfully, but these errors were encountered: