Is there a way to specify port range for SSLSocketFactory and SSLServerSocketFactory

293 Views Asked by At

I am configuring jacorb to use with SSL. The server/client ports picked are random. I need to specify a range of ports much like PortRangeSocketFactory/PortRangeServerSocketFactory in case of non-SSL configuration.

I am trying to avoid OASSLPort property, as the port becomes fixed (instead of range) and applicable for only server/listening ports. Client ports will still be random.

I have a set of processes, some acting as both server and client- with jacorb.properties shared.

Current jacorb.properties configuration:

jacorb.ssl.socket_factory=org.jacorb.security.ssl.sun_jsse.SSLSocketFactory
jacorb.ssl.server_socket_factory=org.jacorb.security.ssl.sun_jsse.SSLServerSocketFactory

I am using Jacorb 3.9, RHEL 7.3 and Java 1.8.0_171.

1

There are 1 best solutions below

0
user3050206 On

Achieved this by writing custom factories:

  1. PortRangeSSLServerSocketFactory extending and composing jsse SSLServerSocketFactory class.

configure() overridden to also read the min/max port config from jacorb.properties.

createServerSocket() overridden to handle port selection. Logic imported from org.jacorb.orb.factory.PortRangeServerSocketFactory.

  1. PortRangeSSLSocketFactory extending AbstractSocketFactory. SSL logic imported from org.jacorb.security.ssl.sun_jsse.SSLSocketFactory and port range selection logic imported from org.jacorb.orb.factory.PortRangeSocketFactory.

Handled multi-homed cases for both via the OAIAddr property.

Pros: Lot of customization possible. Cons: Minimal code usage as many attributes and methods whose logic was implemented were private.