public class HttpsConfigBuilder extends SSLContextBuilder
To use HTTPS in your server, create an HTTPS Config builder and pass it to MuServerBuilder.withHttpsConfig(HttpsConfigBuilder)
Constructor and Description |
---|
HttpsConfigBuilder() |
Modifier and Type | Method and Description |
---|---|
static HttpsConfigBuilder |
httpsConfig() |
static HttpsConfigBuilder |
unsignedLocalhost()
Creates an SSL config builder that will serve HTTPS over a self-signed SSL cert for the localhost domain.
|
HttpsConfigBuilder |
withCipherFilter(SSLCipherFilter cipherFilter)
Sets a filter allowing you to specify which ciphers you would like to support.
|
HttpsConfigBuilder |
withDefaultAlias(String certAlias)
This option may be useful for cases where multiple certificates exist in a single keystore.
|
HttpsConfigBuilder |
withKeyManagerFactory(KeyManagerFactory keyManagerFactory)
Sets the key manager factory to use for SSL.
|
HttpsConfigBuilder |
withKeyPassword(char[] keyPassword) |
HttpsConfigBuilder |
withKeyPassword(String keyPassword) |
HttpsConfigBuilder |
withKeystore(File file) |
HttpsConfigBuilder |
withKeystore(InputStream keystoreStream)
Loads a keystore from the given stream.
|
HttpsConfigBuilder |
withKeystoreFromClasspath(String classpath)
Loads a keystore from the classpath
|
HttpsConfigBuilder |
withKeystorePassword(char[] keystorePassword) |
HttpsConfigBuilder |
withKeystorePassword(String keystorePassword) |
HttpsConfigBuilder |
withKeystoreType(String keystoreType) |
HttpsConfigBuilder |
withProtocols(String... protocols)
Sets the SSL/TLS protocols to use, for example "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3".
|
build, defaultSSLContext, setKeystoreBytes, sslContext, unsignedLocalhostCert, unsignedLocalhostCertBuilder
public static HttpsConfigBuilder httpsConfig()
public HttpsConfigBuilder withKeystoreType(String keystoreType)
withKeystoreType
in class SSLContextBuilder
public HttpsConfigBuilder withKeyPassword(String keyPassword)
withKeyPassword
in class SSLContextBuilder
public HttpsConfigBuilder withKeystorePassword(String keystorePassword)
withKeystorePassword
in class SSLContextBuilder
public HttpsConfigBuilder withKeyPassword(char[] keyPassword)
withKeyPassword
in class SSLContextBuilder
public HttpsConfigBuilder withKeystorePassword(char[] keystorePassword)
withKeystorePassword
in class SSLContextBuilder
public HttpsConfigBuilder withKeystore(InputStream keystoreStream)
Does not close the keystore afterwards.
withKeystore
in class SSLContextBuilder
keystoreStream
- A stream to a keystorepublic HttpsConfigBuilder withKeystore(File file)
withKeystore
in class SSLContextBuilder
public HttpsConfigBuilder withKeystoreFromClasspath(String classpath)
withKeystoreFromClasspath
in class SSLContextBuilder
classpath
- A path to load a keystore from, for example /mycert.p12
public HttpsConfigBuilder withKeyManagerFactory(KeyManagerFactory keyManagerFactory)
Note this is an alternative to setting a keystore directory.
withKeyManagerFactory
in class SSLContextBuilder
keyManagerFactory
- The key manager factory to usepublic HttpsConfigBuilder withDefaultAlias(String certAlias)
Note you do not need to set this if your keystore has only one certificate in it.
withDefaultAlias
in class SSLContextBuilder
certAlias
- The alias of the cert to pick when SNI isn't available, or null to allow an arbitrary
cert to be picked (normally the first one).public HttpsConfigBuilder withCipherFilter(SSLCipherFilter cipherFilter)
withCipherFilter
in class SSLContextBuilder
cipherFilter
- A Filter that takes all the supported ciphers, and all the default ciphers
(normally the default will exclude insecure ciphers that technically could
be supported) and returns a list of ciphers you want to use in your preferred
order.public HttpsConfigBuilder withProtocols(String... protocols)
Note that if the current JDK does not support a requested protocol then it will be ignored. If no requested protocols are available, then an exception will be started when this is built.
withProtocols
in class SSLContextBuilder
protocols
- The protocols to use, or null to use the default.public static HttpsConfigBuilder unsignedLocalhost()
As no clients should trust this cert, this should be used only for testing purposes.
Copyright © 2017–2021. All rights reserved.