org.littleshoot.proxy.mitm.CertificateSniffingMitmManager Java Examples

The following examples show how to use org.littleshoot.proxy.mitm.CertificateSniffingMitmManager. 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: MITMUtility.java    From PowerTunnel with MIT License 5 votes vote down vote up
public static CertificateSniffingMitmManager mitmManager() throws RootCertificateException, IOException {
    char[] password;
    List<String> values = PowerTunnel.SETTINGS.filteredLoad(new DataStore.Filter() {
        @Override
        public boolean accept(String line) {
            return line.startsWith(Settings.ROOT_CA_PASSWORD);
        }
    });
    if(values != null) {
        password = values.get(0).split(Settings.KEY_VALUE_SEPARATOR)[1].toCharArray();
    } else {
        password = UUID.randomUUID().toString().toCharArray();
        PowerTunnel.SETTINGS.setOption(Settings.ROOT_CA_PASSWORD, new String(password));
        PowerTunnel.SETTINGS.save();
        //PowerTunnel.SETTINGS.unload(Settings.ROOT_CA_PASSWORD);
    }
    try {
        return new CertificateSniffingMitmManager(new Authority(new File("."),
                "powertunnel-root-ca", password,
                "PowerTunnel Root CA",
                "PowerTunnel",
                "PowerTunnel",
                "PowerTunnel",
                "PowerTunnel"));
    } finally {
        password = null;
    }
}