com.browserup.bup.mitm.KeyStoreFileCertificateSource Java Examples

The following examples show how to use com.browserup.bup.mitm.KeyStoreFileCertificateSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MitmManagerFactory.java    From vividus with Apache License 2.0 6 votes vote down vote up
@Override
public MitmManager createMitmManager(MitmManagerOptions options)
{
    KeyStoreOptions keyStoreOptions = options.getKeyStoreOptions();
    checkNotNull(keyStoreOptions.getPath(), "key store path");
    checkNotNull(keyStoreOptions.getType(), "key store type");
    checkNotNull(keyStoreOptions.getPassword(), "key store password");
    checkNotNull(options.getAlias(), "alias");

    File keyStore = ResourceUtils.loadFile(getClass(), keyStoreOptions.getPath());
    KeyStoreFileCertificateSource certificateSource = new KeyStoreFileCertificateSource(keyStoreOptions.getType(),
            keyStore, options.getAlias(), keyStoreOptions.getPassword());

    return ImpersonatingMitmManager
            .builder()
            .rootCertificateSource(certificateSource)
            .trustAllServers(options.isTrustAllServers())
            .build();
}
 
Example #2
Source File: CustomCAKeyStoreExample.java    From browserup-proxy with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    // load the root certificate and private key from an existing KeyStore
    KeyStoreFileCertificateSource fileCertificateSource = new KeyStoreFileCertificateSource(
            "PKCS12",                               // KeyStore type. for .jks files (Java KeyStore), use "JKS"
            new File("/path/to/my/keystore.p12"),
            "keyAlias",                             // alias of the private key in the KeyStore; if you did not specify an alias when creating it, use "1"
            "keystorePassword");


    // tell the MitmManager to use the custom certificate and private key
    ImpersonatingMitmManager mitmManager = ImpersonatingMitmManager.builder()
            .rootCertificateSource(fileCertificateSource)
            .build();

    // tell the HttpProxyServerBootstrap to use the new MitmManager
    HttpProxyServer proxyServer = DefaultHttpProxyServer.bootstrap()
            .withManInTheMiddle(mitmManager)
            .start();

    // make your requests to the proxy server
    //...

    proxyServer.abort();
}