Changeset 63f4e04 for router


Ignore:
Timestamp:
Jul 15, 2018 2:39:02 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
2a68a01a
Parents:
6c3cf9bf
Message:

Router: Add CLI tool to generate family keys

Location:
router/java/src/net/i2p/router
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/CommandLine.java

    r6c3cf9bf r63f4e04  
    2121        "net.i2p.router.RouterLaunch",
    2222        "net.i2p.router.RouterVersion",
     23        "net.i2p.router.crypto.FamilyKeyCrypto",
    2324        "net.i2p.router.naming.BlockfileNamingService",
    2425        "net.i2p.router.peermanager.ProfileOrganizer",
  • router/java/src/net/i2p/router/crypto/FamilyKeyCrypto.java

    r6c3cf9bf r63f4e04  
    487487        }
    488488    }
     489
     490    /** @since 0.9.36 */
     491    public static void main(String[] args) {
     492        if (args.length != 2) {
     493            System.err.println("Usage: FamilyKeyCrypto keystore.ks familyname");
     494            System.exit(1);
     495        }
     496        File ks = new File(args[0]);
     497        if (ks.exists()) {
     498            System.err.println("Keystore already exists: " + ks);
     499            System.exit(1);
     500        }
     501        String fname = args[1];
     502        String cname = fname + CN_SUFFIX;
     503        String keyPassword = KeyStoreUtil.randomString();
     504        try {
     505            KeyStoreUtil.createKeysAndCRL(ks, KeyStoreUtil.DEFAULT_KEYSTORE_PASSWORD, fname, cname, "family",
     506                                          DEFAULT_KEY_VALID_DAYS, DEFAULT_KEY_ALGORITHM,
     507                                          DEFAULT_KEY_SIZE, keyPassword);
     508            System.out.println("Family keys generated and saved in " + ks + '\n' +
     509                               "Copy to " + KS_DIR + '/' + KEYSTORE_PREFIX + fname + KEYSTORE_SUFFIX + " in the i2p configuration directory\n" +
     510                               "Family key configuration for router.config:\n" +
     511                               PROP_FAMILY_NAME + '=' +  fname + '\n' +
     512                               PROP_KEYSTORE_PASSWORD + '=' + KeyStoreUtil.DEFAULT_KEYSTORE_PASSWORD + '\n' +
     513                               PROP_KEY_PASSWORD + '=' + keyPassword);
     514        } catch (Exception e) {
     515            System.err.println("Failed");
     516            e.printStackTrace();
     517            System.exit(1);
     518        }
     519    }
    489520}
Note: See TracChangeset for help on using the changeset viewer.