Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Java KeyStore generates keystore files with commands

Shulou Source: shulou.com Published: 2022-06-01 06:25:22 10月04日 Update

1. Generate keyStore file

Execute the following command from the command line:

Shell Code Collection Code

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

Among them

-genkey indicates generation key

-validity specifies the validity period of the certificate. Here it is 36000 days.

-alias specifies an alias. This is www.zlex.org.

-keyalg specifies the algorithm. This is RSA.

-keystore specifies the storage location, here is d:\ zlex.keystore

The password I use here is 123456.

Console output:

Console Code Collection Code

Enter the keystore password: enter the new password again: what is your first and last name? [Unknown]: www.zlex.org what is the name of your organizational unit? [Unknown]: zlex what is the name of your organization? [Unknown]: zlex what is the name of your city or region? [Unknown]: BJ what is the name of your state or province? [Unknown]: what is the two-letter country code of BJ [Unknown]: is CN CN=www.zlex.org, OU=zlex, O=zlex, L=BJ, ST=BJ, C=CN correct? [no]: enter the master password entered by Y (press enter if the password is the same as keystore): enter the new password again:

At this point, a zlex.keystore file will be generated under disk D.

two。 Generate a self-signed certificate

It is not enough to have keyStore files, but also need certificate files. Certificates are the public key certificates that are provided directly to the outside world.

Export Certificate:

Shell Code Collection Code

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

Among them

-export is specified as an export operation

-keystore specifies the keystore file

-alias specifies the alias in the exported keystore file

-file points to the export path

-rfc output in text format, that is, output in BASE64 encoding

The password here is 123456.

Console output:

Console Code Collection Code

Enter the keystore password: authentication saved in the file

Tags: Code file password certificate input generate name output command again alias unit location console new secret control valid same not enough that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Tech Info macOS vpn Linux