-
申请证书,主要需要两个文件:一个是.pfx格式的证书文件,一个是.txt格式的放着密码的文件。
- 上传.pfx文件至服务器上:
- 打开tomcat配置文件,如:/home/web/apache-tomcat-6.0.29/conf/server.xml,修改如下
将这块代码修改为(后期域名访问需要端口为80)
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
在这块代码下面
复制添加如下代码
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="/home/xlApp/tomcatkey/www.boundless-boros.com_1712633884.pfx"
keystorePass="xxx"
clientAuth="false" sslProtocol="TLS" />
注意:
keystoreFile :证书存放目录,可以写绝对路径或Tomcat相对路径;
keystorePass:证书私钥密码;
然后将这行代码注释:
<!--<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />-->
最后打开tomcat根目录conf下web.xml文件,在文件倒数第二行加上这段:(按esc,输入:$ 可以直接到文件末尾)
<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即可