美文网首页
tomcat安装https协议

tomcat安装https协议

作者: 圈圈_Emily | 来源:发表于2020-07-01 11:46 被阅读0次

1. 在jkd安装目录 找到 jdk1.8.0/bin/keytool.exe

2. 在命令提示符窗口进入到jdk1.8.0/bin/路径下, 执行一下语句, san=ip: IP地址为需要安装https的服务器IP,  -keystore为指定的生成文件的全路径.


keytool -genkey -alias tomcat  -storetype PKCS12 -keyalg RSA -keysize 2048  -keystore d:\keystore.p12 -validity 3650  -ext san=ip:172.0.0.1 -dname "CN=garyyan, OU=mycompany, O=mycompany, L=gd, ST=gd, C=china"


会提示你输入密码, 然后回车, 再确认一次密码, 回车, 

123456

123456

3. 继续执行如下命令, -keystore d:\keystore.p12 为上一行命令配置的路径, -file d:\cer.cer为要生成的证书的全路径 -storepass 后面接着前面输入的密码


keytool -export -keystore d:\keystore.p12 -alias tomcat -file d:\182cer.cer -storepass 123456


4. 将keystore.p12 以及 cer.cer 拷贝到需要安装https的服务器任意目录下

5. 在需要安装https的服务器tomcat的/conf/server.xml, 增加配置如下:

maxHttpHeaderSize是请求信息大小.keystoreFile是服务器上的p12文件的路径, keystorePass为密码, 好像也不需要182cer.cer


<Connector port="8443" protocol="HTTP/1.1"

    maxThreads="150" SSLEnabled="true" schema="https"

    secure="true" clientAuth="false" sslProtocol="TLS"

    keystoreFile="/opt/keystore.p12"

    keystoreType="pkcs12"

    keystorePass="123456"

    maxHttpHeaderSize="102400" />


6. 在tomcat的/conf/catalina.properties文件的最后加上


tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}

org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true


7. 强制http跳转https, 在tomcat的/conf/web.xml的</welcome-file-list>后面添加如下代码


<login-config>

          <!-- Authorization setting for SSL -->

          <auth-method>CLIENT-CERT</auth-method>

          <realm-name>Client Cert Users-only Area</realm-name>

      </login-config>

      <security-constraint>

          <!-- Authorization setting for SSL -->

          <web-resource-collection>

          <web-resource-name>SSL</web-resource-name>

          <url-pattern>/*</url-pattern>

          </web-resource-collection>

          <user-data-constraint>

          <transport-guarantee>CONFIDENTIAL</transport-guarantee>

          </user-data-constraint>

      </security-constraint>


相关文章

网友评论

      本文标题:tomcat安装https协议

      本文链接:https://www.haomeiwen.com/subject/hwscqktx.html