tomcat中配置https服务

在conf/server.xml中,配置一个

<Connector port="9000" 
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" debug="0" scheme="https" secure="true"

               clientAuth="false" sslProtocol="TLS" keystoreFile="/conf/keystore" keystorePass="123456"/> 

 其中, scheme="https"声明此服务是https服务,keystoreFile="/conf/keystore"指定了keystore文件的路径,keystorePass指定了密码。

将准备好的keystore文件放至指定的目录下。启动tomcat,就可以通过9000端口访问此服务了。

注: 

clientAuth指定是否需要验证客户端证书,如果为false,则在客户端访问的时候,如果验证客户端无证书,会弹出对话框提醒用户:“您要查看的网站要求标识,请选择证书”,

 

如果你要求客户端在访问时弹出这个对话框,就把clientAuth设为true。

原文地址:https://www.cnblogs.com/mabaishui/p/1981460.html