Class TCPSSLOptions

java.lang.Object
io.vertx.core.net.NetworkOptions
io.vertx.core.net.TCPSSLOptions
Direct Known Subclasses:
ClientOptionsBase, EventBusOptions, NetServerOptions

public abstract class TCPSSLOptions extends NetworkOptions
Base class. TCP and SSL related options
Author:
Tim Fox
  • Field Details

    • DEFAULT_TCP_NO_DELAY

      public static final boolean DEFAULT_TCP_NO_DELAY
      The default value of TCP-no-delay = true (Nagle disabled)
      See Also:
    • DEFAULT_TCP_KEEP_ALIVE

      public static final boolean DEFAULT_TCP_KEEP_ALIVE
      The default value of TCP keep alive = false
      See Also:
    • DEFAULT_SO_LINGER

      public static final int DEFAULT_SO_LINGER
      The default value of SO_linger = -1
      See Also:
    • DEFAULT_SSL

      public static final boolean DEFAULT_SSL
      SSL enable by default = false
      See Also:
    • DEFAULT_IDLE_TIMEOUT

      public static final int DEFAULT_IDLE_TIMEOUT
      Default idle timeout = 0
      See Also:
    • DEFAULT_IDLE_TIMEOUT_TIME_UNIT

      public static final TimeUnit DEFAULT_IDLE_TIMEOUT_TIME_UNIT
      Default idle time unit = SECONDS
    • DEFAULT_READ_IDLE_TIMEOUT

      public static final int DEFAULT_READ_IDLE_TIMEOUT
      Default read idle timeout = 0
      See Also:
    • DEFAULT_WRITE_IDLE_TIMEOUT

      public static final int DEFAULT_WRITE_IDLE_TIMEOUT
      Default write idle timeout = 0
      See Also:
    • DEFAULT_SSL_ENGINE

      public static final SSLEngineOptions DEFAULT_SSL_ENGINE
      The default SSL engine options = null (autoguess)
    • DEFAULT_TCP_FAST_OPEN

      public static final boolean DEFAULT_TCP_FAST_OPEN
      The default TCP_FASTOPEN value = false
      See Also:
    • DEFAULT_TCP_CORK

      public static final boolean DEFAULT_TCP_CORK
      The default TCP_CORK value = false
      See Also:
    • DEFAULT_TCP_QUICKACK

      public static final boolean DEFAULT_TCP_QUICKACK
      The default TCP_QUICKACK value = false
      See Also:
    • DEFAULT_TCP_USER_TIMEOUT

      public static final int DEFAULT_TCP_USER_TIMEOUT
      The default TCP_USER_TIMEOUT value in milliseconds = 0

      When the default value of 0 is used, TCP will use the system default.

      See Also:
    • DEFAULT_TCP_KEEAPLIVE_IDLE_SECONDS

      public static final int DEFAULT_TCP_KEEAPLIVE_IDLE_SECONDS
      Default value for tcp keepalive idle time.

      A value of 0 means: Do not set this socket option, which will result in an OS-specific default value.

      See Also:
    • DEFAULT_TCP_KEEAPLIVE_COUNT

      public static final int DEFAULT_TCP_KEEAPLIVE_COUNT
      Default value for tcp keepalive count.

      A value of 0 means: Do not set this socket option, which will result in an OS-specific default value.

      See Also:
    • DEFAULT_TCP_KEEAPLIVE_INTERVAL_SECONDS

      public static final int DEFAULT_TCP_KEEAPLIVE_INTERVAL_SECONDS
      Default value for tcp keepalive interval.

      A value of 0 means: Do not set this socket option, which will result in an OS-specific default value.

      See Also:
  • Constructor Details

    • TCPSSLOptions

      public TCPSSLOptions()
      Default constructor
    • TCPSSLOptions

      public TCPSSLOptions(TCPSSLOptions other)
      Copy constructor
      Parameters:
      other - the options to copy
    • TCPSSLOptions

      public TCPSSLOptions(JsonObject json)
      Create options from JSON
      Parameters:
      json - the JSON
  • Method Details

    • toJson

      public JsonObject toJson()
      Convert to JSON
      Specified by:
      toJson in class NetworkOptions
      Returns:
      the JSON
    • getOrCreateSSLOptions

      protected SSLOptions getOrCreateSSLOptions()
    • createSSLOptions

      protected SSLOptions createSSLOptions()
    • getTransportOptions

      public TcpConfig getTransportOptions()
    • getSslOptions

      public SSLOptions getSslOptions()
    • getSendBufferSize

      public int getSendBufferSize()
      Description copied from class: NetworkOptions
      Return the TCP send buffer size, in bytes.
      Specified by:
      getSendBufferSize in class NetworkOptions
      Returns:
      the send buffer size
    • setSendBufferSize

      public TCPSSLOptions setSendBufferSize(int sendBufferSize)
      Description copied from class: NetworkOptions
      Set the TCP send buffer size
      Specified by:
      setSendBufferSize in class NetworkOptions
      Parameters:
      sendBufferSize - the buffers size, in bytes
      Returns:
      a reference to this, so the API can be used fluently
    • getReceiveBufferSize

      public int getReceiveBufferSize()
      Description copied from class: NetworkOptions
      Return the TCP receive buffer size, in bytes
      Specified by:
      getReceiveBufferSize in class NetworkOptions
      Returns:
      the receive buffer size
    • setReceiveBufferSize

      public TCPSSLOptions setReceiveBufferSize(int receiveBufferSize)
      Description copied from class: NetworkOptions
      Set the TCP receive buffer size
      Specified by:
      setReceiveBufferSize in class NetworkOptions
      Parameters:
      receiveBufferSize - the buffers size, in bytes
      Returns:
      a reference to this, so the API can be used fluently
    • isReuseAddress

      public boolean isReuseAddress()
      Specified by:
      isReuseAddress in class NetworkOptions
      Returns:
      the value of reuse address
    • setReuseAddress

      public TCPSSLOptions setReuseAddress(boolean reuseAddress)
      Description copied from class: NetworkOptions
      Set the value of reuse address
      Specified by:
      setReuseAddress in class NetworkOptions
      Parameters:
      reuseAddress - the value of reuse address
      Returns:
      a reference to this, so the API can be used fluently
    • getTrafficClass

      public int getTrafficClass()
      Specified by:
      getTrafficClass in class NetworkOptions
      Returns:
      the value of traffic class
    • setTrafficClass

      public TCPSSLOptions setTrafficClass(int trafficClass)
      Description copied from class: NetworkOptions
      Set the value of traffic class
      Specified by:
      setTrafficClass in class NetworkOptions
      Parameters:
      trafficClass - the value of traffic class
      Returns:
      a reference to this, so the API can be used fluently
    • isReusePort

      public boolean isReusePort()
      Specified by:
      isReusePort in class NetworkOptions
      Returns:
      the value of reuse address - only supported by native transports
    • setReusePort

      public TCPSSLOptions setReusePort(boolean reusePort)
      Description copied from class: NetworkOptions
      Set the value of reuse port.

      This is only supported by native transports.

      Specified by:
      setReusePort in class NetworkOptions
      Parameters:
      reusePort - the value of reuse port
      Returns:
      a reference to this, so the API can be used fluently
    • isTcpNoDelay

      public boolean isTcpNoDelay()
      Returns:
      TCP no delay enabled ?
    • setTcpNoDelay

      public TCPSSLOptions setTcpNoDelay(boolean tcpNoDelay)
      Set whether TCP no delay is enabled
      Parameters:
      tcpNoDelay - true if TCP no delay is enabled (Nagle disabled)
      Returns:
      a reference to this, so the API can be used fluently
    • isTcpKeepAlive

      public boolean isTcpKeepAlive()
      Returns:
      is TCP keep alive enabled?
    • setTcpKeepAlive

      public TCPSSLOptions setTcpKeepAlive(boolean tcpKeepAlive)
      Set whether TCP keep alive is enabled
      Parameters:
      tcpKeepAlive - true if TCP keep alive is enabled
      Returns:
      a reference to this, so the API can be used fluently
    • getSoLinger

      public int getSoLinger()
      Returns:
      is SO_linger enabled
    • setSoLinger

      public TCPSSLOptions setSoLinger(int soLinger)
      Set whether SO_linger keep alive is enabled
      Parameters:
      soLinger - true if SO_linger is enabled
      Returns:
      a reference to this, so the API can be used fluently
    • setIdleTimeout

      public TCPSSLOptions setIdleTimeout(int idleTimeout)
      Set the idle timeout, default time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed if no data is received nor sent within the timeout. If you want change default time unit, use setIdleTimeoutUnit(TimeUnit)
      Parameters:
      idleTimeout - the timeout
      Returns:
      a reference to this, so the API can be used fluently
    • getIdleTimeout

      public int getIdleTimeout()
      Returns:
      the idle timeout, in time unit specified by getIdleTimeoutUnit().
    • setReadIdleTimeout

      public TCPSSLOptions setReadIdleTimeout(int idleTimeout)
      Set the read idle timeout, default time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed if no data is received within the timeout. If you want change default time unit, use setIdleTimeoutUnit(TimeUnit)
      Parameters:
      idleTimeout - the read timeout
      Returns:
      a reference to this, so the API can be used fluently
    • getReadIdleTimeout

      public int getReadIdleTimeout()
      Returns:
      the read idle timeout, in time unit specified by getIdleTimeoutUnit().
    • setWriteIdleTimeout

      public TCPSSLOptions setWriteIdleTimeout(int idleTimeout)
      Set the write idle timeout, default time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed if no data is sent within the timeout. If you want change default time unit, use setIdleTimeoutUnit(TimeUnit)
      Parameters:
      idleTimeout - the write timeout
      Returns:
      a reference to this, so the API can be used fluently
    • getWriteIdleTimeout

      public int getWriteIdleTimeout()
      Returns:
      the write idle timeout, in time unit specified by getIdleTimeoutUnit().
    • setIdleTimeoutUnit

      public TCPSSLOptions setIdleTimeoutUnit(TimeUnit idleTimeoutUnit)
      Set the idle timeout unit. If not specified, default is seconds.
      Parameters:
      idleTimeoutUnit - specify time unit.
      Returns:
      a reference to this, so the API can be used fluently
    • getIdleTimeoutUnit

      public TimeUnit getIdleTimeoutUnit()
      Returns:
      the idle timeout unit.
    • isSsl

      public boolean isSsl()
      Returns:
      is SSL/TLS enabled?
    • setSsl

      public TCPSSLOptions setSsl(boolean ssl)
      Set whether SSL/TLS is enabled
      Parameters:
      ssl - true if enabled
      Returns:
      a reference to this, so the API can be used fluently
    • getKeyCertOptions

      public KeyCertOptions getKeyCertOptions()
      Returns:
      the key/cert options
    • setKeyCertOptions

      public TCPSSLOptions setKeyCertOptions(KeyCertOptions options)
      Set the key/cert options.
      Parameters:
      options - the key store options
      Returns:
      a reference to this, so the API can be used fluently
    • getTrustOptions

      public TrustOptions getTrustOptions()
      Returns:
      the trust options
    • setTrustOptions

      public TCPSSLOptions setTrustOptions(TrustOptions options)
      Set the trust options.
      Parameters:
      options - the trust options
      Returns:
      a reference to this, so the API can be used fluently
    • addEnabledCipherSuite

      public TCPSSLOptions addEnabledCipherSuite(String suite)
      Add an enabled cipher suite, appended to the ordered suites.
      Parameters:
      suite - the suite
      Returns:
      a reference to this, so the API can be used fluently
      See Also:
    • removeEnabledCipherSuite

      public TCPSSLOptions removeEnabledCipherSuite(String suite)
      Removes an enabled cipher suite from the ordered suites.
      Parameters:
      suite - the suite
      Returns:
      a reference to this, so the API can be used fluently
    • getEnabledCipherSuites

      public Set<String> getEnabledCipherSuites()
      Return an ordered set of the cipher suites.

      The set is initially empty and suite should be added to this set in the desired order.

      When suites are added and therefore the list is not empty, it takes precedence over the default suite defined by the SSLEngineOptions in use.

      Returns:
      the enabled cipher suites
    • getCrlPaths

      public List<String> getCrlPaths()
      Returns:
      the CRL (Certificate revocation list) paths
    • addCrlPath

      public TCPSSLOptions addCrlPath(String crlPath) throws NullPointerException
      Add a CRL path
      Parameters:
      crlPath - the path
      Returns:
      a reference to this, so the API can be used fluently
      Throws:
      NullPointerException
    • getCrlValues

      public List<Buffer> getCrlValues()
      Get the CRL values
      Returns:
      the list of values
    • addCrlValue

      public TCPSSLOptions addCrlValue(Buffer crlValue) throws NullPointerException
      Add a CRL value
      Parameters:
      crlValue - the value
      Returns:
      a reference to this, so the API can be used fluently
      Throws:
      NullPointerException
    • isUseAlpn

      public boolean isUseAlpn()
      Returns:
      whether to use or not Application-Layer Protocol Negotiation
    • setUseAlpn

      public TCPSSLOptions setUseAlpn(boolean useAlpn)
      Set the ALPN usage.
      Parameters:
      useAlpn - true when Application-Layer Protocol Negotiation should be used
    • getSslEngineOptions

      public SSLEngineOptions getSslEngineOptions()
      Returns:
      the SSL engine implementation to use
    • setSslEngineOptions

      public TCPSSLOptions setSslEngineOptions(SSLEngineOptions sslEngineOptions)
      Set to use SSL engine implementation to use.
      Parameters:
      sslEngineOptions - the ssl engine to use
      Returns:
      a reference to this, so the API can be used fluently
    • setEnabledSecureTransportProtocols

      public TCPSSLOptions setEnabledSecureTransportProtocols(Set<String> enabledSecureTransportProtocols)
      Sets the list of enabled SSL/TLS protocols.
      Parameters:
      enabledSecureTransportProtocols - the SSL/TLS protocols to enable
      Returns:
      a reference to this, so the API can be used fluently
    • addEnabledSecureTransportProtocol

      public TCPSSLOptions addEnabledSecureTransportProtocol(String protocol)
      Add an enabled SSL/TLS protocols, appended to the ordered protocols.
      Parameters:
      protocol - the SSL/TLS protocol to enable
      Returns:
      a reference to this, so the API can be used fluently
    • removeEnabledSecureTransportProtocol

      public TCPSSLOptions removeEnabledSecureTransportProtocol(String protocol)
      Removes an enabled SSL/TLS protocol from the ordered protocols.
      Parameters:
      protocol - the SSL/TLS protocol to disable
      Returns:
      a reference to this, so the API can be used fluently
    • isTcpFastOpen

      public boolean isTcpFastOpen()
      Returns:
      wether TCP_FASTOPEN option is enabled
    • setTcpFastOpen

      public TCPSSLOptions setTcpFastOpen(boolean tcpFastOpen)
      Enable the TCP_FASTOPEN option - only with linux native transport.
      Parameters:
      tcpFastOpen - the fast open value
    • isTcpCork

      public boolean isTcpCork()
      Returns:
      wether TCP_CORK option is enabled
    • setTcpCork

      public TCPSSLOptions setTcpCork(boolean tcpCork)
      Enable the TCP_CORK option - only with linux native transport.
      Parameters:
      tcpCork - the cork value
    • isTcpQuickAck

      public boolean isTcpQuickAck()
      Returns:
      wether TCP_QUICKACK option is enabled
    • setTcpQuickAck

      public TCPSSLOptions setTcpQuickAck(boolean tcpQuickAck)
      Enable the TCP_QUICKACK option - only with linux native transport.
      Parameters:
      tcpQuickAck - the quick ack value
    • getTcpUserTimeout

      public int getTcpUserTimeout()
      Returns:
      the TCP_USER_TIMEOUT value
    • setTcpUserTimeout

      public TCPSSLOptions setTcpUserTimeout(int tcpUserTimeout)
      Sets the TCP_USER_TIMEOUT option - only with linux native transport.
      Parameters:
      tcpUserTimeout - the tcp user timeout value
    • getTcpKeepAliveIdleSeconds

      public int getTcpKeepAliveIdleSeconds()
      Returns:
      the time in seconds the connection needs to remain idle before TCP starts sending keepalive probes
    • setTcpKeepAliveIdleSeconds

      public TCPSSLOptions setTcpKeepAliveIdleSeconds(int tcpKeepAliveIdleSeconds)
      The time in seconds the connection needs to remain idle before TCP starts sending keepalive probes, if the socket option keepalive has been set.

      Only works with linux native support (EPoll, IoUring).

      Parameters:
      tcpKeepAliveIdleSeconds - idle time in seconds
      Returns:
      a reference to this, so the API can be used fluently
    • getTcpKeepAliveCount

      public int getTcpKeepAliveCount()
      Returns:
      the maximum number of keepalive probes TCP should send before dropping the connection.
    • setTcpKeepAliveCount

      public TCPSSLOptions setTcpKeepAliveCount(int tcpKeepAliveCount)
      The maximum number of keepalive probes TCP should send before dropping the connection.

      Only works with linux native support (EPoll, IoUring).

      Parameters:
      tcpKeepAliveCount - number of probes
      Returns:
      a reference to this, so the API can be used fluently
    • getTcpKeepAliveIntervalSeconds

      public int getTcpKeepAliveIntervalSeconds()
      Returns:
      the time in seconds between individual keepalive probes (while the channel is idle).
    • setTcpKeepAliveIntervalSeconds

      public TCPSSLOptions setTcpKeepAliveIntervalSeconds(int tcpKeepAliveIntervalSeconds)
      The time in seconds between individual keepalive probes (while the channel is idle).

      Only works with linux native support (EPoll, IoUring).

      Parameters:
      tcpKeepAliveIntervalSeconds - interval in seconds
      Returns:
      a reference to this, so the API can be used fluently
    • getEnabledSecureTransportProtocols

      public Set<String> getEnabledSecureTransportProtocols()
      Returns the enabled SSL/TLS protocols
      Returns:
      the enabled protocols
    • getSslHandshakeTimeout

      public long getSslHandshakeTimeout()
      Returns:
      the SSL handshake timeout, in time unit specified by getSslHandshakeTimeoutUnit().
    • setSslHandshakeTimeout

      public TCPSSLOptions setSslHandshakeTimeout(long sslHandshakeTimeout)
      Set the SSL handshake timeout, default time unit is seconds.
      Parameters:
      sslHandshakeTimeout - the SSL handshake timeout to set, in milliseconds
      Returns:
      a reference to this, so the API can be used fluently
    • setSslHandshakeTimeoutUnit

      public TCPSSLOptions setSslHandshakeTimeoutUnit(TimeUnit sslHandshakeTimeoutUnit)
      Set the SSL handshake timeout unit. If not specified, default is seconds.
      Parameters:
      sslHandshakeTimeoutUnit - specify time unit.
      Returns:
      a reference to this, so the API can be used fluently
    • getSslHandshakeTimeoutUnit

      public TimeUnit getSslHandshakeTimeoutUnit()
      Returns:
      the SSL handshake timeout unit.
    • setLogActivity

      public TCPSSLOptions setLogActivity(boolean logEnabled)
      Description copied from class: NetworkOptions
      Set to true to enabled network activity logging: Netty's pipeline is configured for logging on Netty's logger.
      Overrides:
      setLogActivity in class NetworkOptions
      Parameters:
      logEnabled - true for logging the network activity
      Returns:
      a reference to this, so the API can be used fluently