argList = net.i2p.i2ptunnel.web.SSLHelper.parseArgs(clArgs);
for (String arg : argList) {
if (arg.endsWith("jetty.xml")) {
jettyFile = new File(arg);
if (!jettyFile.isAbsolute())
jettyFile = new File(ctx.getConfigDir(), arg);
jettySSLFileInArgs = true;
} else if (arg.endsWith("jetty-ssl.xml")) {
jettySSLFile = new File(arg);
if (!jettySSLFile.isAbsolute())
jettySSLFile = new File(ctx.getConfigDir(), arg);
jettySSLFileInArgs = true;
}
} // for arg in argList
if (jettySSLFile == null && !argList.isEmpty()) {
String arg = argList.get(0);
File f = new File(arg);
if (!f.isAbsolute())
f = new File(ctx.getConfigDir(), arg);
File p = f.getParentFile();
if (p != null)
jettySSLFile = new File(p, "jetty-ssl.xml");
}
boolean ksDflt = false;
boolean kmDflt = false;
boolean tsDflt = false;
boolean ksExists = false;
if (jettyFile != null && jettyFile.exists()) {
try {
org.eclipse.jetty.xml.XmlParser.Node root;
root = net.i2p.jetty.JettyXmlConfigurationParser.parse(jettyFile);
host = JettyXmlConfigurationParser.getValue(root, "host");
port = JettyXmlConfigurationParser.getValue(root, "port");
} catch (org.xml.sax.SAXException saxe) {
saxe.printStackTrace();
error = DataHelper.escapeHTML(saxe.getMessage());
}
}
if (jettySSLFile.exists()) {
try {
org.eclipse.jetty.xml.XmlParser.Node root;
root = net.i2p.jetty.JettyXmlConfigurationParser.parse(jettySSLFile);
ksPW = JettyXmlConfigurationParser.getValue(root, "KeyStorePassword");
kmPW = JettyXmlConfigurationParser.getValue(root, "KeyManagerPassword");
tsPW = JettyXmlConfigurationParser.getValue(root, "TrustStorePassword");
ksPath = JettyXmlConfigurationParser.getValue(root, "KeyStorePath");
tsPath = JettyXmlConfigurationParser.getValue(root, "TrustStorePath");
sslHost = JettyXmlConfigurationParser.getValue(root, "host");
sslPort = JettyXmlConfigurationParser.getValue(root, "port");
// we can't proceed unless they are there
// tsPW may be null
File ksFile = null;
boolean tsIsKs = true;
boolean ksArgs = ksPW != null && kmPW != null && ksPath != null;
/** 2015+ installs */
final String DEFAULT_KSPW_1 = KeyStoreUtil.DEFAULT_KEYSTORE_PASSWORD;
final String DEFAULT_KMPW_1 = "myKeyPassword";
/** earlier */
final String DEFAULT_KSPW_2 = "OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4";
final String DEFAULT_KMPW_2 = "OBF:1u2u1wml1z7s1z7a1wnl1u2g";
if (ksArgs) {
jettySSLFileExists = true;
ksDflt = ksPW.equals(DEFAULT_KSPW_1) || ksPW.equals(DEFAULT_KSPW_2);
kmDflt = kmPW.equals(DEFAULT_KMPW_1) || kmPW.equals(DEFAULT_KMPW_2);
ksFile = new File(ksPath);
if (!ksFile.isAbsolute())
ksFile = new File(ctx.getConfigDir(), ksPath);
ksExists = ksFile.exists();
tsIsKs = tsPath == null || ksPath.equals(tsPath);
}
if (tsPW != null) {
tsDflt = tsPW.equals(DEFAULT_KSPW_1) || tsPW.equals(DEFAULT_KSPW_2);
}
} catch (org.xml.sax.SAXException saxe) {
saxe.printStackTrace();
error = DataHelper.escapeHTML(saxe.getMessage());
}
}
boolean canConfigure = jettySSLFileExists;
boolean isEnabled = canConfigure && jettySSLFileInArgs;
boolean isPWDefault = kmDflt || !ksExists;
// now start the output for this client
%>
<%=DataHelper.escapeHTML(clName)%>
<%
for (String arg : argList) {
%><%=DataHelper.escapeHTML(arg)%> <%
}
%>
<%=start%> <%=ssl%> <%=ksExists%> <%=error%> <%=ksDflt%> <%=kmDflt%>
<%
if (!canConfigure) {
%>
Cannot configure, no Jetty SSL configuration template exists
<%
} else {
if (isEnabled) {
%>
Jetty SSL is enabled
<%
} else {
%>
Jetty SSL is not enabled
<%
} // isEnabled
if (isPWDefault) {
%>
Jetty SSL cert passwords are the default
<%
} else {
%>
Jetty SSL cert passwords are not the default
<%
} // isPWDefault
%>
<%=intl._t("Password")%>:
" value="" class="freetext password" />
<%=intl._t("Generate certificate")%>
<%
} // canConfigure
} // for client
} catch (java.io.IOException ioe) { ioe.printStackTrace(); }
%>
">