不用keytool,tomcat打开https
?
publicstaticvoid main(String[] args) throws Exception {
??????
?????? //trustsotre, my root certificate
?????? KeyStore store = KeyStore.getInstance("JKS");
?????? // initialize
??? ??? store.load(null, null);
??? ??? KeyPair rootPair = generateKeyPair();
?????? X500PrivateCredential rootCredential = createRootCredential(rootPair);
?????? store.setCertificateEntry(TRUST_STORE_NAME, rootCredential.getCertificate());
?????? store.store(
??????????????? new FileOutputStream(TRUST_STORE_NAME + ".jks"),
??????????????? TRUST_STORE_PASSWORD);
?????? // server credentials
?????? store = KeyStore.getInstance("JKS");
?????? store.load(null, null);
??????? store.setKeyEntry(
????????? SERVER_NAME, rootCredential.getPrivateKey(), SERVER_PASSWORD,
??????????????? new Certificate[] { rootCredential.getCertificate() });
??????? store.store(
????????? new FileOutputStream(SERVER_NAME + ".jks"), SERVER_PASSWORD);
??? }
?
?
?