Tomcat启用HTTPS/SSL

coding

  1. 生成 key

    # $JAVA_HOME/bin/keytool \

    -genkeypair \

    -keyalg RSA \

    -keysize 2048 \

    -keystore tomcat.jks \

    -alias tomcat \

    -storepass yourpass \

    -keypass yourpass \

    -dname "CN=YourName, OU=YourOrg, O=Your Company, L=YourCity, S=YourState, C=CN"

    特别说明:上边输入的“-storepass”和“-keypass“ 2个密码一定要相同,否则TOMCAT起不来。

    参考:

    1. http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/keytool.html
    2. http://www-01.ibm.com/software/webservers/hostondemand/library/v8infocenter/ssh-pk03.html
  2. 然后将生成的 tomcat.jks 文件 copy 到 $CATALINA_BASE/conf 目录

  3. 编辑 $CATALINA_BASE/conf/server.xml

    打开下面的配置

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

    maxThreads="150" scheme="https" secure="true"

    clientAuth="false" sslProtocol="TLS"

    keystoreFile="./conf/tomcat.jks"

    keystoreType="JKS"

    keystorePass="yourpass"

    ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA"

    />

    • keystoreFile: 就是刚才创建的证书文件,这里使用的是相对目录,也就是tomcat根目录.
    • keystorePass: 是你创建证书时输入的密码.
    • ciphers: 用来解决 chrome 45+ ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY 问题(http://stackoverflow.com/questions/30931692/diffie-hellman-public-key-error-with-tomcat-7)
  4. 启动 Tomcat

以上是 Tomcat启用HTTPS/SSL 的全部内容, 来源链接: utcz.com/z/510045.html

回到顶部