首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

不要keytool,tomcat打开https

2012-09-19 
不用keytool,tomcat打开https? publicstaticvoid main(String[] args) throws Exception {?????? ?????? /

不用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);

??? }

?



?

?

热点排行