Utils: Allow absolute path to certs in I2PSSLSocketFactory

This commit is contained in:
zzz
2019-05-11 13:37:18 +00:00
parent f6efdceaca
commit 9eec35713c
3 changed files with 41 additions and 11 deletions

View File

@ -237,7 +237,7 @@ public class I2PSSLSocketFactory {
private final I2PAppContext _context; 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 * @since 0.9.9 was static
*/ */
public I2PSSLSocketFactory(I2PAppContext context, boolean loadSystemCerts, String relativeCertPath) public I2PSSLSocketFactory(I2PAppContext context, boolean loadSystemCerts, String relativeCertPath)
@ -468,7 +468,10 @@ public class I2PSSLSocketFactory {
/** /**
* Loads certs from * 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) private static SSLSocketFactory initSSLContext(I2PAppContext context, boolean loadSystemCerts, String relativeCertPath)
throws GeneralSecurityException { 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 adds = KeyStoreUtil.addCerts(dir, ks);
int totalAdds = adds; int totalAdds = adds;
if (adds > 0) { if (adds > 0) {
@ -495,14 +501,20 @@ public class I2PSSLSocketFactory {
log.info("Loaded " + adds + " trusted certificates from " + dir.getAbsolutePath()); log.info("Loaded " + adds + " trusted certificates from " + dir.getAbsolutePath());
} }
File dir2 = new File(context.getBaseDir(), relativeCertPath); File dir2;
if (!dir.getAbsolutePath().equals(dir2.getAbsolutePath())) { if (!wasAbsolute) {
adds = KeyStoreUtil.addCerts(dir2, ks); dir2 = new File(context.getBaseDir(), relativeCertPath);
totalAdds += adds; if (!dir.getAbsolutePath().equals(dir2.getAbsolutePath())) {
if (adds > 0) { adds = KeyStoreUtil.addCerts(dir2, ks);
if (log.shouldLog(Log.INFO)) totalAdds += adds;
log.info("Loaded " + adds + " trusted certificates from " + dir.getAbsolutePath()); 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 (totalAdds > 0 || loadSystemCerts) {
if (log.shouldLog(Log.INFO)) if (log.shouldLog(Log.INFO))

View File

@ -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-07 0.9.40 released
2019-05-02 zzz 2019-05-02 zzz

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 1; public final static long BUILD = 2;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "";