美文网首页
SpringBoot配置https访问 (使用p12证书)

SpringBoot配置https访问 (使用p12证书)

作者: oceanfive | 来源:发表于2020-03-07 22:18 被阅读0次

    [TOC]

    SpringBoot配置https访问 (使用p12证书)

    需求清单

    • 云服务器ECS
    • 域名
    • SSL证书

    步骤

    去阿里云官网后台下载SSL证书

    image

    因为使用p12配置https访问,这里选择的Nginx类型证书下载

    image

    解压证书

    image

    登录云服务

    通过终端使用 ssh 登录服务器

    新建文件夹,用来存放证书相关

    mkdir -p /root/cer
    

    拷贝 crtkey文件

    使用scp 命令把本地电脑上的证书文件(crtkey文件)拷贝到服务器的文件夹下(/root/cer):

    scp -r 本地电脑.crt文件路径 root@112.112.11.11:/root/cer
    

    在云服务器上执行命令生产 server.p12 文件

    openssl pkcs12 -export -clcerts -in xxx.crt -inkey xxx.key -out server.p12 
    
    image

    把服务器上生成的 server.p12 证书下载到自己电脑上

    命令仍然是 scp

    把下载下来的证书添加到项目中,位置在 resources 目录下

    image

    .properties 文件中配置 ssl 访问

    image

    使用https访问

    image

    把应用发布到服务器上进行访问

    image

    参考文章

    https://www.jianshu.com/p/eb52e0f5ee85

    相关文章

      网友评论

          本文标题:SpringBoot配置https访问 (使用p12证书)

          本文链接:https://www.haomeiwen.com/subject/nsekdhtx.html