tomcat 配置 ssl证书

参考链接:https://blog.csdn.net/u012811841/article/details/80389792

1.根据证书生成jks文件

keytool -importkeystore -srckeystore 1723057_www.aaa365.com.pfx -destkeystore aaa.jks -srcstoretype PKCS12 -deststoretype JKS

2.将生成的jks文件放到tomcat/conf下

server文件修改,注意域名的配置

<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true" defaultSSLHostConfigName="www.safely365.com">
        <SSLHostConfig hostName="www.safely365.com">
            <Certificate certificateKeystoreFile="conf/aaa.jks"
				certificateKeystorePassword="123456"/>
        </SSLHostConfig>
    </Connector>

web.xml修改

<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>

猜你喜欢

转载自blog.csdn.net/zhangyongbink/article/details/86299617