配置HTTPS 这里使用的是tomcat8
1 2 3 4 5 6 7 8 9 10 11 12 13 <Connector port ="8080" protocol ="HTTP/1.1" connectionTimeout ="20000" redirectPort ="443" /> <Connector port ="443" protocol ="org.apache.coyote.http11.Http11Nio2Protocol" maxThreads ="150" SSLEnabled ="true" scheme ="https" secure ="true" > <SSLHostConfig > <Certificate certificateKeystoreFile ="cert/tomcat.jks" certificateKeyAlias ="1" certificateKeystorePassword ="123456" type ="RSA" /> </SSLHostConfig > </Connector > <Connector port ="8009" protocol ="AJP/1.3" redirectPort ="443" />
Connector的certificateKeyAlias和type可以使用下边的命令在cmd中查看。使用的是java的keytool工具
1 2 keytool -v -list -keystore tomcat.jks
运行tomcat后,如果有这个提示The AJP Connector is configured with secretRequired="true" but the secret attribute is either null or "". This combination is not valid. 那么就在AJP/1.3中再插入一个属性secretRequired=""即可
tomcat8.x配置HTTPS
server.xml解析 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 <Server port ="8005" shutdown ="SHUTDOWN" > <Service name ="Catalina" > <Executor ...... /> <Connector ...... /> <Connector ...... /> <Engine name ="Catalina" defaultHost ="localhost" > <Host name ="localhost" appBase ="webapps" unpackWARs ="true" autoDeploy ="true" > <Alias > doc.a.com</Alias > <Context docBase ="/home/project/" reloadable ="true" /> <Valve ...... /> </Host > </Engine > </Service > </Server >
参考