小程序https如何购买、配置

在阿里云找到SSL证书页面,阿里云提供免费的SSL证书

img_039a62b18bef7a83cd7693413058bf99.png
image.png

选择品牌

img_ddf609053c12262b3b0ad87076d6548b.png
image.png

选择免费型

img_74e2e3e3de22dec37abb0712af63f6f7.png
image.png

进入控制台就可以看到已经购买的证书了

img_60e101f1a3ffe2c9b2a15ca5f0033660.png
image.png

补全信息

img_98af56d4f0580e47e2fe7cfb671db9d6.png
image.png

后面忘了截图,大概有以下几个步骤:

  1. 将文件上传到服务器指定位置,需要URL能够访问到(非https)
  2. 指定位置是一个隐藏文件夹,window下需要用mkdir命令创建
  3. 上传文件过一会就会自动验证成功
  4. 第3步很容易失败,建议直接在服务器上下载验证文件,多试几次

配置Apache或者Nginx

# 添加 SSL 协议支持协议,去掉不安全的协议
SSLProtocol all -SSLv2 -SSLv3
# 修改加密套件如下
SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
SSLHonorCipherOrder on
# 证书公钥配置
SSLCertificateFile cert/public.pem
# 证书私钥配置
SSLCertificateKeyFile cert/215045620450170.key
# 证书链配置,如果该属性开头有 '#'字符,请删除掉
SSLCertificateChainFile cert/chain.pem
server {
    listen 443;
    server_name localhost;
    ssl on;
    root html;
    index index.html index.htm;
    ssl_certificate   cert/215045620450170.pem;
    ssl_certificate_key  cert/215045620450170.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    location / {
        root html;
        index index.html index.htm;
    }
}

分享一下我最终的配置(Apache虚拟站点)

<VirtualHost *:443>
    SSLEngine on
    ServerName demo.com:443
    SSLCertificateKeyFile "${SRVROOT}/conf/ssl_dict/215045620450170.key"
    SSLCertificateFile "${SRVROOT}/conf/ssl_dict/public.pem"
    SSLCertificateChainFile "${SRVROOT}/conf/ssl_dict/chain.pem"

    DocumentRoot "E:\wwwroot\demo.com\public"
    ServerName demo.com
    ServerAlias demo.com
    
    #START-ERROR-PAGE
    ErrorDocument 403 /403.html
    ErrorDocument 404 /404.html
    ErrorDocument 502 /502.html
    #END-ERROR-PAGE
    
    #startPHP
    <Files ~ "\.php$">
        Options FollowSymLinks ExecCGI
        AddHandler fcgid-script .php
        FcgidWrapper "E:/BtSoft/WebSoft/php/7.1/php-cgi.exe" .php
    </Files>
    #endPHP
    
    #start301
    #end301
    
    #REFERER-START
    #REFERER-END
    
    #PROXY-START
    #PROXY-END
    <Directory "E:\wwwroot\demo.com\public">
        Options FollowSymLinks ExecCGI
        AllowOverride All
        Require all granted
        DirectoryIndex index.php default.php index.html index.htm default.html default.htm
        
    </Directory>
    ErrorLog "logs/demo.com-error.log"
    CustomLog "logs/demo.com-access.log" common
</VirtualHost>

推荐一个https相关的资料站 https://github.com/cheaphttps/https-start

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值