Crypto: Create keystore directory when making SSL keys (ticket #1866)

When we switched to new way of making keys in 0.9.25,
we omitted the mkdir step, which broke it.
This commit is contained in:
zzz
2016-10-23 16:38:26 +00:00
parent 85223303f2
commit 80966d60c1
3 changed files with 22 additions and 1 deletions

View File

@ -591,6 +591,12 @@ public final class KeyStoreUtil {
public static Object[] createKeysAndCRL(File ks, String ksPW, String alias, String cname, String ou,
int validDays, SigType type, String keyPW)
throws GeneralSecurityException, IOException {
File dir = ks.getParentFile();
if (dir != null && !dir.exists()) {
File sdir = new SecureDirectory(dir.getAbsolutePath());
if (!sdir.mkdirs())
throw new IOException("Can't create directory " + dir);
}
Object[] rv = SelfSignedGenerator.generate(cname, ou, "XX", "I2P Anonymous Network", "XX", "XX", validDays, type);
PublicKey jpub = (PublicKey) rv[0];
PrivateKey jpriv = (PrivateKey) rv[1];