[Android Tutorial Series Part 27] How to use the Keytool tool to generate a keystore signature file

This is the 27th article of the [Android Tutorial Series]. If you find it useful, please pay attention to the column.

One: What is Keytool?

Keytool is a key and certificate management tool that allows users to manage their own public keys, private keys, related certificates, and generally used for authentication services.

Two: Does Keytool need to be installed?

Keytool is a data certificate management tool that comes with Java. Because it comes with it, we don't need to install it. You can use Keytool directly if you have JDK or JRE on your computer.

For example, the location of my local keytool is as shown below
insert image description here

Three: The storage form of the Keytool key

The Keytool tool stores the key Key and certificate certificates in a keystore file, so the keystore file only contains two kinds of data

  • Key entity: If the form of asymmetric encryption is used, it contains the private key and the paired public key, otherwise, only the key is included.
  • Trusted Certificate Entity: That is, only contains the public key.

Four: Keytool generates keystore signature file

Using Keytool to generate a keystore signature file is very simple, just need to execute a command on the terminal, and then enter a few pieces of information, as shown in the following code

keytool -genkey -v -keystore allensu.keystore -alias allensu -storepass 123456 -keypass 123456 -keyalg RSA -validity 36000

Each parameter is explained below

  • genkey: Indicates the generation of a key pair, that is, a public key and a private key.
  • keystore: Set the generated file name followed .Keystoreby a suffix of .
  • alias: The alias of the key, this name is public.
  • storepass: Generate the password for the keystore file.
  • keypass: Set the password of the key.
  • keyalg: Specifies the algorithm of the key, generally set to RSA, default DSA.
  • validity: How many days the certificate is valid for.

Enter this command in the terminal, as shown in the figure below. The
insert image description here
above command means to generate allensu.keystorea , its alias is allensu, the password of the keystore file is 123456, the password of the key is 123456, the algorithm is RSAtype , and the validity period of the certificate is36000 sky.

Enter the rest as prompted.

When it is displayed that allensu.keystore is being stored, you can see the generated signature file in the current directory, as shown in the figure above.
insert image description here
So far, how to use the Keytool tool to generate the Keystore signature file has been introduced.

Has your problem been resolved? Welcome to leave a message in the comment area.

Give someone a rose, and there is a lingering fragrance in your hand. If you think the article is good, I hope you can give a one-click three-link, thank you.


concluding remarks

Technology is accumulated little by little, and God cannot be achieved in a day. Staying still is going backwards, so make a little bit of progress every day.

Finally, a motto is attached: "I am eager to learn, but humble as a fool", and I hope to encourage each other.

Guess you like

Origin blog.csdn.net/qq_42351033/article/details/122291396