当前位置:   article > 正文

tomcat,nginx中部署ssl证书,http转化为https_tomcat ssl证书与nginx证书

tomcat ssl证书与nginx证书

当时的环境:阿里云的域名,腾讯云的服务器。在阿里云上面申请的免费ssl证书。根据你的服务器下载相应的ssl证书,我下的是tomcat和nginx两个版本的。

首先在tomcat中部署ssl:

       1. 解压在阿里云申请的ssl证书,共有两个文件,一个pfx版的证书,一个密码txt。在tomcat安装目录下的conf文件夹中新建cert文件夹,将证书和密码文件通过xftp传送到该文件夹下。

        2.通过命令将PFX格式证书转换为JKS格式证书

keytool -importkeystore -srckeystore 你的证书名称.pfx -destkeystore 新证书的名字.jks -srcstoretype PKCS12 -deststoretype JKS

        3.回车,会提示你输入密码,建议三次都输入密码txt中的密码。

        4.修改server.xml文件

添加<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
              maxThreads="150" scheme="https" secure="true"
              keystoreFile="证书的路径" 
              keystorePass=" 密码txt中的密码"  
              clientAuth="false" sslProtocol="TLS" />

将8443修改为443

        5.在web.xml文件中末尾处添加如下代码:

<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配置ssl,将http转化为https。

效果图:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/885346
推荐阅读
相关标签
  

闽ICP备14008679号