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;
}
}
public Server start() throws Exception {
BouncyCastleSslEngineSource es = new BouncyCastleSslEngineSource(
new Authority(), true, true);
SubjectAlternativeNameHolder san = new SubjectAlternativeNameHolder();
// san.addDomainName("localhost");
es.initializeServerCertificates(commonName, san);
File certChainFile = new File("littleproxy-mitm-" + commonName
+ "-cert.pem");
File keyFile = new File("littleproxy-mitm-" + commonName + "-key.pem");
return initServerContext(certChainFile, keyFile);
}
public String getCerPath(){
return mKeyStoreDir + File.separator + Authority.CER_ALIAS + Authority.CER_FILE_EXTENSION;
}