Package com.ngrok
Class TlsBuilder
- java.lang.Object
-
- com.ngrok.MetadataBuilder<T>
-
- com.ngrok.EndpointBuilder<TlsBuilder>
-
- com.ngrok.TlsBuilder
-
- All Implemented Interfaces:
Forwarder.Builder<Forwarder.Endpoint>
,Listener.Builder<Listener.Endpoint>
public class TlsBuilder extends EndpointBuilder<TlsBuilder> implements Listener.Builder<Listener.Endpoint>, Forwarder.Builder<Forwarder.Endpoint>
A builder for creating a TLS endpoint listener
-
-
Constructor Summary
Constructors Constructor Description TlsBuilder(Session session)
Creates a newTlsBuilder
with a given session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TlsBuilder
domain(String domain)
Sets the domain to request for this TLS endpoint.Forwarder.Endpoint
forward(URL url)
Start listening and forwarding connections to given url.Optional<String>
getDomain()
Returns the domain to request for this TLS endpoint.byte[]
getMutualTLSCA()
Returns the certificates to use for client authentication for this TLS endpoint.byte[]
getTerminationCertPEM()
Sets the certificate to use for TLS termination for this TLS endpoint.byte[]
getTerminationKeyPEM()
Sets the key to use for TLS termination for this TLS endpoint.Listener.Endpoint
listen()
Starts listening and accepting new connections.TlsBuilder
mutualTLSCA(byte[] mutualTLSCA)
Sets the certificates to use for client authentication for this TLS endpoint.TlsBuilder
termination(byte[] terminationCertPEM, byte[] terminationKeyPEM)
Sets the certificate and key to use for TLS termination for this TLS endpoint.-
Methods inherited from class com.ngrok.EndpointBuilder
allowCIDR, denyCIDR, getAllowCIDR, getDenyCIDR, getPolicy, getProxyProto, getProxyProtoVersion, getTrafficPolicy, policy, proxyProto, trafficPolicy
-
Methods inherited from class com.ngrok.MetadataBuilder
forwardsTo, getForwardsTo, getMetadata, metadata
-
-
-
-
Constructor Detail
-
TlsBuilder
public TlsBuilder(Session session)
Creates a newTlsBuilder
with a given session.- Parameters:
session
- the session over which this listener will connect. Ifnull
,listen()
andforward(URL)
will throwNullPointerException
, use the corresponding methods on theSession
object directly.
-
-
Method Detail
-
domain
public TlsBuilder domain(String domain)
Sets the domain to request for this TLS endpoint. Any valid domain or hostname that you have previously registered with ngrok. If using a custom domain, this requires registering in the ngrok dashboard and setting a DNS CNAME value.- Parameters:
domain
- the domain- Returns:
- the builder instance
-
mutualTLSCA
public TlsBuilder mutualTLSCA(byte[] mutualTLSCA)
Sets the certificates to use for client authentication for this TLS endpoint.- Parameters:
mutualTLSCA
- the TLS certificate, in bytes- Returns:
- the builder instance
- See Also:
- Mutual TLS in the ngrok docs for additional details.
-
termination
public TlsBuilder termination(byte[] terminationCertPEM, byte[] terminationKeyPEM)
Sets the certificate and key to use for TLS termination for this TLS endpoint.- Parameters:
terminationCertPEM
- the TLS certificate, in bytesterminationKeyPEM
- the TLS key, in bytes- Returns:
- the builder instance
- See Also:
- TLS Termination in the ngrok docs for additional details.
-
getDomain
public Optional<String> getDomain()
Returns the domain to request for this TLS endpoint.- Returns:
- the domain
-
getMutualTLSCA
public byte[] getMutualTLSCA()
Returns the certificates to use for client authentication for this TLS endpoint.- Returns:
- the TLS certificates, in bytes.
-
getTerminationCertPEM
public byte[] getTerminationCertPEM()
Sets the certificate to use for TLS termination for this TLS endpoint.- Returns:
- the TLS termination certificate, in bytes.
-
getTerminationKeyPEM
public byte[] getTerminationKeyPEM()
Sets the key to use for TLS termination for this TLS endpoint.- Returns:
- the TLS termination key, in bytes.
-
listen
public Listener.Endpoint listen() throws IOException
Description copied from interface:Listener.Builder
Starts listening and accepting new connections.- Specified by:
listen
in interfaceListener.Builder<Listener.Endpoint>
- Returns:
- the concrete
Listener
instance - Throws:
IOException
- if an I/O error occurs
-
forward
public Forwarder.Endpoint forward(URL url) throws IOException
Description copied from interface:Forwarder.Builder
Start listening and forwarding connections to given url.- Specified by:
forward
in interfaceForwarder.Builder<Forwarder.Endpoint>
- Parameters:
url
- to forward connections to- Returns:
- the concrete
Forwarder
instance - Throws:
IOException
- if an I/O error occurs
-
-