JAVA WEB应用HTTPS方式部署访问时,自签名证书的生成步骤(IP版本)

概念介绍:

  • JSSE(Java Secure Socket Extension)。java web应用利用JSSE实现SSL/TSL安全协议
  • keystore、truststore:JSSE使用keystore与truststore文件来提供客户端和服务器之间的安全数据传输
  • keytool:jdk自带的可以用来创建自签名证书与keystore文件的工具

自签名步骤:

  1. 生成一个含有私钥的keystore文件:
    keytool -genkeypair -alias andy_keystore_ip -keyalg RSA -validity 36500 -keystore andy_keystore_ip.jks -ext san=ip:172.22.144.16

    1步骤操作后,会生成andy_keystore_ip.jks文件

  2. 利用keystore文件导出凭证文件

    keytool -export -alias andy_keystore_ip -keystore andy_keystore_ip.jks -rfc -file andy_cer_ip.cer

  3. 将证书文件导入到truststore文件中

    keytool -import -alias andy_truststore_ip -file andy_cer_ip.cer -keystore andy_truststore_ip.jks

  4. 将安全证书andy_cer_ip.cer复制web服务运行的jdk安装目录的jre/lib/security目录中:

  5. 将安全证书导入到jdk的keystore cacerts文件中,cacerts文件默认密码changeit

    keytool -import -alias andy_keystore_ip -keystore cacerts -file andy_cer_ip.cer

     

  6. 重启web服务即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章