zoukankan      html  css  js  c++  java
  • JDK8给Tomcat配置https

    第一步:生成秘钥库

    采用JDK自带的keytool工具生成秘钥
    别名 xieh1234 存储路径 D:\cas\keystore\

    keytool -genkey -v -alias xieh1234 -keyalg RSA -keystore D:\cas\keystore\xieh1234.keystore
    

    -alias 表示证书的别名,一个keystore文件中可以存放多个alias。
    -keyalg RSA 表示密钥算法的名称为RSA算法
    -keystore是生成的或者已有的keystore文件的位置,如果不提供的话,keytool工具会把它放在用户目录下,还起了个名字叫.keystore。

    此时提示输入 秘钥库口令组织信息组织信息填写域名,地区信息就填真实的就行。

    例:注:不参考图片中的命令

    第二步:从秘钥库导出证书

    keytool -export -trustcacerts -alias xieh1234 -file D:\cas\keystore\xieh1234.cer -keystore D:\cas\keystore\xieh1234.keystore
    

    输入第一步的秘钥库密码

    即可生成证书  xieh1234.cer

    第三步:将证书导入到JDK证书库

    keytool -import -trustcacerts -alias xieh1234 -file D:/cas/keystore/xieh1234.cer -keystore "D:/software/jdk1.8/jre/lib/security/cacerts"
    

    输入密码:changeit       这是固定密码

    第四步:tomcat配置

    找到tomcat->conf->server.xml打开文件
    加入如下配置即可

     <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
       maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
       clientAuth="false" sslProtocol="TLS"
       keystoreFile="D:\cas\keystore\xieh1234.keystore" keystorePass="第一步输入的秘钥库密码"
    	/>
    

    启动tomcat即可。控制台中文乱码解决:

    打开:tomcat->conf->logging.properties打开文件中:
    java.util.logging.ConsoleHandler.encoding = UTF-8
    改成
    java.util.logging.ConsoleHandler.encoding = GBK
    就好了

  • 相关阅读:
    231. Power of Two
    204. Count Primes
    205. Isomorphic Strings
    203. Remove Linked List Elements
    179. Largest Number
    922. Sort Array By Parity II
    350. Intersection of Two Arrays II
    242. Valid Anagram
    164. Maximum Gap
    147. Insertion Sort List
  • 原文地址:https://www.cnblogs.com/xiejn/p/15770220.html
Copyright © 2011-2022 走看看