You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updating dependencies for GreenMail and Jakarta Mail resulted in "CertificateException: No subject alternative names present" during test execution using DummySSLSocketFactory
#832
Open
gunalmel opened this issue
Jan 6, 2025
· 1 comment
If the java mail client uses
properties.put("mail.smtps.ssl.checkserveridentity", "false");
then
Security.setProperty("ssl.SocketFactory.provider", DummySSLSocketFactory.class.getName());
works fine without the need for java keystore as it was before. That's inconvenient because the java email client has to be modified to use different props when it's running in production.
Replacing the use of DummySSLSocketFactory with a keystore resolved the issue.
Keystore Creation:
Removed Security.setProperty("ssl.SocketFactory.provider", DummySSLSocketFactory.class.getName()); Instead created a keystore for the tests and specified it as trust store at the same time.
Test Setup Code (Before):
The following setup code worked with the previous dependencies:
Previous Dependencies:
Current Dependencies:
After updating to the following dependencies:
the following error occurs during tests:
Code Under Test:
The following method triggers the error:
Workarounds:
If the java mail client uses
properties.put("mail.smtps.ssl.checkserveridentity", "false");
then
Security.setProperty("ssl.SocketFactory.provider", DummySSLSocketFactory.class.getName());
works fine without the need for java keystore as it was before. That's inconvenient because the java email client has to be modified to use different props when it's running in production.
Replacing the use of DummySSLSocketFactory with a keystore resolved the issue.
Keystore Creation:
Removed Security.setProperty("ssl.SocketFactory.provider", DummySSLSocketFactory.class.getName()); Instead created a keystore for the tests and specified it as trust store at the same time.
Updated Test Setup (@BeforeAll):
When the test is run alone the workarounds worked fine. When it's run in a suite with many other tests using gradle it still fails with:
Expected Behavior:
The DummySSLSocketFactory should bypass SSL validation without requiring additional keystore configuration.
Observed Behavior:
Tests fail with java.security.cert.CertificateException: No subject alternative names present.
The text was updated successfully, but these errors were encountered: