简体   繁体   English

如何通过Java keytool命令行界面生成x.509证书

[英]How to generate x.509 certificate by the Java keytool command-line interface

I am using RESTEasy encryption. 我正在使用RESTEasy加密。 For that I have to generate x.509 certificate by the Java 'keytool' command-line interface. 为此,我必须通过Java'keytool'命令行界面生成x.509证书。

Please help me 请帮我

Thank you 谢谢

This is the command to generate self signed certificates. 这是生成自签名证书的命令。 All in one line 全部在一条线上

keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks 
        -storepass password -validity 360 -keysize 2048

When you run this command, it will ask you for the details of the signatory. 运行此命令时,它会询问您签名者的详细信息。 These will be the details of your organization. 这些将是您组织的详细信息。 Provide all the details and it will create a new self signed certificate in keystore keystore for you. 提供所有详细信息,它将为您在密钥keystore密钥keystore创建一个新的自签名证书。

NOTE: When it ask for your first and last name, give the domain name of the server which will be the entry point for your users. 注意:当它询问您的姓名时,请提供服务器的域名,该域名将是您的用户的入口点。 ie www.myserver.com 即www.myserver.com

If you already have a keystore then you can use your existing keystore to add new certificate otherwise this command will create the keystore keystore.jks with the password and add the certificate to the new keystore. 如果您已有密钥库,则可以使用现有密钥库添加新证书,否则此命令将使用password创建密钥keystore.jks ,并将证书添加到新密钥库。 Note that if you already have a keystore then you need to provide the password of the existing keystore in -storepass parameter of this command. 请注意,如果您已有密钥库,则需要在此命令的-storepass参数中提供现有密钥库的密码。

For more details, see the keytool man page: http://docs.oracle.com/javase/1.5.0/docs/tooldocs/solaris/keytool.html 有关更多详细信息,请参见keytool手册页: http//docs.oracle.com/javase/1.5.0/docs/tooldocs/solaris/keytool.html

Here you will find details of all the available options you can use with the keytool command. 在这里,您将找到可以与keytool命令一起使用的所有可用选项的详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM