mail-api icon indicating copy to clipboard operation
mail-api copied to clipboard

Add support for custom HostnameVerifier with Secure Sockets

Open icu5545 opened this issue 3 years ago • 3 comments

This PR is to provide the ability to utilize a custom HostnameVerifier implementation when using a secure socket for mail transport. This provides the ability for consumers of the API to use a pre-existing hostname verification implementation as opposed to performing additional, potentially redundant, error-prone property configuration.

icu5545 avatar Jul 12 '21 17:07 icu5545

I think you should convert this code so that we are storing the string of the class name used to construct the HostnameVerifier. I don't think we want to add a constructed HostnameVerifier to the properties object. This would be similar to how we create services in the session class. https://github.com/eclipse-ee4j/mail/blob/master/mail/src/main/java/jakarta/mail/Session.java#L788 or how we create Folder subclasses in IMAP.

jmehrens avatar Jul 22 '21 15:07 jmehrens

@jmehrens Agreed, a string-based option should definitely be made available. I'm basing the implementation on the existing code within the SocketFetcher. E.g. SocketFactory resolution: https://github.com/eclipse-ee4j/mail/blob/dc446219e3276878031cac02d6ff7b42a1e8717c/mail/src/main/java/com/sun/mail/util/SocketFetcher.java#L149-L183

EDIT: It occurs to me that the implementations are virtually the same.

I'm not sure if you're suggesting it, but I'm not comfortable completely eliminating the ability to provide an object within the properties. First, the precedent is set, and keeps this implementation in line with existing functionality. And, second, because the HostnameVerifier interface does not provide any specifics into construction mechanics, imposing one-size-fits-all constructor or singleton handling does not seem to make sense.

icu5545 avatar Jul 22 '21 16:07 icu5545

@icu5545 That seem fine to allow implementation and string based like socket factory.

jmehrens avatar Sep 07 '21 14:09 jmehrens

Moved the PR to https://github.com/eclipse-ee4j/angus-mail/pull/126 If I do a backport to v1.x I'll create a new PR based of the Angus Mail version.

jmehrens avatar Feb 14 '24 05:02 jmehrens