Java KeyStore generating KeyStore files with commands

Source: Internet
Author: User
Tags rfc

1. Generate the KeyStore file
Execute the following command at the command line:
Shell Code Collection Code

keytool -genkey -validity 36000 -alias www.zlex.org -keyalg RSA -keystore d:\zlex.keystore  

which
-genkey indicates that the key is generated
-validity Specify the certificate validity period, here is 36,000 days
-ALIAS Specifies the alias, this is www.zlex.org
-KEYALG Specifies the algorithm, here is the RSA
-keystore Specify the storage location, this is D:\zlex.keystore

The password I used here is 123456.

Console output:
Console Code Collection code

输入keystore密码:  再次输入新密码:  您的名字与姓氏是什么?    [Unknown]:  www.zlex.org  您的组织单位名称是什么?    [Unknown]:  zlex  您的组织名称是什么?    [Unknown]:  zlex  您所在的城市或区域名称是什么?    [Unknown]:  BJ  您所在的州或省份名称是什么?    [Unknown]:  BJ  该单位的两字母国家代码是什么    [Unknown]:  CN  CN=www.zlex.org, OU=zlex, O=zlex, L=BJ, ST=BJ, C=CN 正确吗?    [否]:  Y  输入<tomcat>的主密码          (如果和 keystore 密码相同,按回车):  再次输入新密码:  

At this point, a Zlex.keystore file is generated under the D drive.

2. Generate a self-signed certificate
Light has KeyStore file is not enough, also need certificate file, certificate is directly provided to the outside public key credentials.
To export a certificate:
Shell Code Collection Code

keytool -export -keystore d:\zlex.keystore -alias www.zlex.org -file d:\zlex.cer -rfc  

which
-export specified as an export operation
-keystore Specifying KeyStore files
-alias specifying an alias in the export KeyStore file
-file pointing to the export path
-RFC output in text format, i.e. output in BASE64 encoding
The code here is 123456.

Console output:
Console Code Collection code

输入keystore密码:  保存在文件中的认证 <d:\zlex.cer>  

Java KeyStore using commands to generate KeyStore files

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.