Package org.littleshoot.proxy.extras
Class SelfSignedSslEngineSource
- java.lang.Object
-
- org.littleshoot.proxy.extras.SelfSignedSslEngineSource
-
- All Implemented Interfaces:
SslEngineSource
public class SelfSignedSslEngineSource extends Object implements SslEngineSource
BasicSslEngineSourcefor testing. TheSSLContextuses self-signed certificates that are generated lazily if the given key store file doesn't yet exist.
-
-
Field Summary
Fields Modifier and Type Field Description private Stringaliasprivate StringkeyStoreFileprivate static org.slf4j.LoggerLOGprivate Stringpasswordprivate static StringPROTOCOLprivate booleansendCertsprivate SSLContextsslContextprivate booleantrustAllServers
-
Constructor Summary
Constructors Constructor Description SelfSignedSslEngineSource()SelfSignedSslEngineSource(boolean trustAllServers)SelfSignedSslEngineSource(boolean trustAllServers, boolean sendCerts)SelfSignedSslEngineSource(String keyStorePath)SelfSignedSslEngineSource(String keyStorePath, boolean trustAllServers, boolean sendCerts)SelfSignedSslEngineSource(String keyStorePath, boolean trustAllServers, boolean sendCerts, String alias, String password)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SSLContextgetSslContext()private voidinitializeKeyStore(File keyStoreLocalFile)private voidinitializeSSLContext()private KeyStoreloadKeyStore()private voidloadKeyStore(KeyStore keyStore, URL url)private StringnativeCall(String... commands)SSLEnginenewSslEngine()Returns anSSLEngineto use for a server connection from LittleProxy to the client.SSLEnginenewSslEngine(String peerHost, int peerPort)Returns anSSLEngineto use for a client connection from LittleProxy to the upstream server.
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
PROTOCOL
private static final String PROTOCOL
- See Also:
- Constant Field Values
-
alias
private final String alias
-
password
private final String password
-
keyStoreFile
private final String keyStoreFile
-
trustAllServers
private final boolean trustAllServers
-
sendCerts
private final boolean sendCerts
-
sslContext
private SSLContext sslContext
-
-
Constructor Detail
-
SelfSignedSslEngineSource
public SelfSignedSslEngineSource(String keyStorePath, boolean trustAllServers, boolean sendCerts, String alias, String password)
-
SelfSignedSslEngineSource
public SelfSignedSslEngineSource(String keyStorePath, boolean trustAllServers, boolean sendCerts)
-
SelfSignedSslEngineSource
public SelfSignedSslEngineSource(String keyStorePath)
-
SelfSignedSslEngineSource
public SelfSignedSslEngineSource(boolean trustAllServers)
-
SelfSignedSslEngineSource
public SelfSignedSslEngineSource(boolean trustAllServers, boolean sendCerts)
-
SelfSignedSslEngineSource
public SelfSignedSslEngineSource()
-
-
Method Detail
-
newSslEngine
public SSLEngine newSslEngine()
Description copied from interface:SslEngineSourceReturns anSSLEngineto use for a server connection from LittleProxy to the client.- Specified by:
newSslEnginein interfaceSslEngineSource
-
newSslEngine
public SSLEngine newSslEngine(String peerHost, int peerPort)
Description copied from interface:SslEngineSourceReturns anSSLEngineto use for a client connection from LittleProxy to the upstream server. * Note: Peer information is needed to send the server_name extension in handshake with Server Name Indication (SNI).- Specified by:
newSslEnginein interfaceSslEngineSource- Parameters:
peerHost- to start a client connection to the server.peerPort- to start a client connection to the server.
-
getSslContext
public SSLContext getSslContext()
-
initializeKeyStore
private void initializeKeyStore(File keyStoreLocalFile)
-
initializeSSLContext
private void initializeSSLContext()
-
loadKeyStore
private KeyStore loadKeyStore() throws IOException, GeneralSecurityException
- Throws:
IOExceptionGeneralSecurityException
-
loadKeyStore
private void loadKeyStore(KeyStore keyStore, URL url) throws IOException, GeneralSecurityException
- Throws:
IOExceptionGeneralSecurityException
-
-