From 9eec35713c4052cec2ea1ccab31b0c56e6d1b48d Mon Sep 17 00:00:00 2001 From: zzz Date: Sat, 11 May 2019 13:37:18 +0000 Subject: [PATCH] Utils: Allow absolute path to certs in I2PSSLSocketFactory --- .../src/net/i2p/util/I2PSSLSocketFactory.java | 32 +++++++++++++------ history.txt | 18 +++++++++++ .../src/net/i2p/router/RouterVersion.java | 2 +- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/core/java/src/net/i2p/util/I2PSSLSocketFactory.java b/core/java/src/net/i2p/util/I2PSSLSocketFactory.java index 23252bb5b..aa6f2203a 100644 --- a/core/java/src/net/i2p/util/I2PSSLSocketFactory.java +++ b/core/java/src/net/i2p/util/I2PSSLSocketFactory.java @@ -237,7 +237,7 @@ public class I2PSSLSocketFactory { private final I2PAppContext _context; /** - * @param relativeCertPath e.g. "certificates/i2cp" + * @param relativeCertPath e.g. "certificates/i2cp"; as of 0.9.41, may be absolute * @since 0.9.9 was static */ public I2PSSLSocketFactory(I2PAppContext context, boolean loadSystemCerts, String relativeCertPath) @@ -468,7 +468,10 @@ public class I2PSSLSocketFactory { /** * Loads certs from - * the ~/.i2p/certificates/ and $I2P/certificates/ directories. + * the ~/.i2p/certificates/ and $I2P/certificates/ directories, + * or from the absolute path given. + * + * @param relativeCertPath e.g. "certificates/i2cp"; as of 0.9.41, may be absolute */ private static SSLSocketFactory initSSLContext(I2PAppContext context, boolean loadSystemCerts, String relativeCertPath) throws GeneralSecurityException { @@ -487,7 +490,10 @@ public class I2PSSLSocketFactory { } } - File dir = new File(context.getConfigDir(), relativeCertPath); + File dir = new File(relativeCertPath); + boolean wasAbsolute = dir.isAbsolute(); + if (!wasAbsolute) + dir = new File(context.getConfigDir(), relativeCertPath); int adds = KeyStoreUtil.addCerts(dir, ks); int totalAdds = adds; if (adds > 0) { @@ -495,14 +501,20 @@ public class I2PSSLSocketFactory { log.info("Loaded " + adds + " trusted certificates from " + dir.getAbsolutePath()); } - File dir2 = new File(context.getBaseDir(), relativeCertPath); - if (!dir.getAbsolutePath().equals(dir2.getAbsolutePath())) { - adds = KeyStoreUtil.addCerts(dir2, ks); - totalAdds += adds; - if (adds > 0) { - if (log.shouldLog(Log.INFO)) - log.info("Loaded " + adds + " trusted certificates from " + dir.getAbsolutePath()); + File dir2; + if (!wasAbsolute) { + dir2 = new File(context.getBaseDir(), relativeCertPath); + if (!dir.getAbsolutePath().equals(dir2.getAbsolutePath())) { + adds = KeyStoreUtil.addCerts(dir2, ks); + totalAdds += adds; + if (adds > 0) { + if (log.shouldLog(Log.INFO)) + log.info("Loaded " + adds + " trusted certificates from " + dir.getAbsolutePath()); + } } + } else { + // for logging below + dir2 = dir; } if (totalAdds > 0 || loadSystemCerts) { if (log.shouldLog(Log.INFO)) diff --git a/history.txt b/history.txt index 766a210c2..9838bebb5 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,21 @@ +2019-05-11 zzz + * Utils: Allow absolute path to certs in I2PSSLSocketFactory + +2019-05-10 zzz + * NetDB: Store Meta LS2 to floodfills (proposal #123) + +2019-05-09 zzz + * Console: + - Delay plugin update check until router is ready + - Remove plugin install success message (ticket #2494) + * Transport: Start first GeoIP lookup when netdb is ready + * Wrapper: + - Add support for armv7 and aarch64 (ticket #2308) + - Update to 3.5.39 + +2019-05-08 zzz + * Utils: Auto-generate su3 output file for extract if not specified + * 2019-05-07 0.9.40 released 2019-05-02 zzz diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 87e5bffca..282c18b42 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 1; + public final static long BUILD = 2; /** for example "-test" */ public final static String EXTRA = "";