%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA -keystore  E:\keystore 
保存为一个bat文件,运行填入相关信息。E:\keystore就是证书文件。
然后在server.xml中加入:
<Connector className="org.apache.catalina.connector.http.HttpConnector"
               port="443" minProcessors="5" maxProcessors="75"
               enableLookups="true"
       acceptCount="10" debug="0" scheme="https" secure="true">
      <Factory className="org.apache.catalina.net.SSLServerSocketFactory"
               clientAuth="false" protocol="TLS"
        keystoreFile="E:\keystore" keystorePass="changeit"       
               />
    </Connector>http和https必须使用两个不同的端口,设置一个目录是否要证书,只需要在访问时把http改为https(前提是http和https使用的是默认的端口,80和443,不然改为https时需要指点端口号)