Package org.microproxy.tls
Class KeyStoreSslContextSource
java.lang.Object
org.microproxy.tls.KeyStoreSslContextSource
- All Implemented Interfaces:
SslContextSource
An
SslContextSource for the proxy's own TLS listener, presenting the certificate of a key
store entry (PKCS#12 or JKS): the HTTPS and HTTP/2 listener (withSslContextSource), and,
through getKeyMaterial(java.lang.String), the HTTP/3 listener of a reverse proxy. Peer certificates are
checked against the JDK's default trust store, which matters only with client authentication.
MicroProxy.bootstrap()
.withReverseProxy("https://backend.internal")
.withSslContextSource(new KeyStoreSslContextSource(Path.of("site.p12"), "secret".toCharArray()))
.withHttp3(true)
.start();
-
Constructor Summary
ConstructorsConstructorDescriptionKeyStoreSslContextSource(Path keyStore, char[] password) Presents the first key entry of a key store file, whose type (PKCS#12 or JKS) is detected.KeyStoreSslContextSource(KeyStore keyStore, String alias, char[] password) Presents a key store entry. -
Method Summary
Modifier and TypeMethodDescriptiongetKeyMaterial(String serverName) The entry's chain and key, whatever name the client asks for.Returns the TLS context for this connection.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.microproxy.SslContextSource
configure
-
Constructor Details
-
KeyStoreSslContextSource
Presents the first key entry of a key store file, whose type (PKCS#12 or JKS) is detected.- Parameters:
keyStore- the key store filepassword- the key store's password, which is also the entry's- Throws:
IOException- if the file cannot be read, or holds no usable key entry
-
KeyStoreSslContextSource
public KeyStoreSslContextSource(KeyStore keyStore, String alias, char[] password) throws IOException Presents a key store entry.- Parameters:
keyStore- the loaded key storealias- the key entry's alias, or null for the first key entrypassword- the entry's password- Throws:
IOException- if the key store has no such key entry, or it cannot be read
-
-
Method Details
-
getSslContext
Description copied from interface:SslContextSourceReturns the TLS context for this connection.- Specified by:
getSslContextin interfaceSslContextSource- Returns:
- the TLS context for this connection
-
getKeyMaterial
The entry's chain and key, whatever name the client asks for.- Specified by:
getKeyMaterialin interfaceSslContextSource- Parameters:
serverName- the server name the client asked for (SNI), or null if it sent none- Returns:
- the chain and key to present, or null if this source has none
-