美文网首页
https免费证书申请

https免费证书申请

作者: 亻火子 | 来源:发表于2019-11-29 16:29 被阅读0次

    证书有两种,一种是 ECC 证书(内置公钥是 ECDSA 公钥),一种是 RSA 证书(内置 RSA 公钥)。简单来说,同等长度 ECC 比 RSA 更安全,也就是说在具有同样安全性的情况下,ECC 的密钥长度比 RSA 短得多(加密解密会更快)。但问题是 ECC 的兼容性会差一些,Android 4.x 以下和 Windows XP 不支持。只要您的设备不是非常老的老古董,建议使用 ECC 证书。

    以下是ECC证书的生成方法。

    1.安装 acme.sh

    # curl https://get.acme.sh | sh
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   705    0   705    0     0   6488      0 --:--:-- --:--:-- --:--:--  6527
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  190k  100  190k    0     0   776k      0 --:--:-- --:--:-- --:--:--  774k
    [Fri Nov 29 15:42:34 CST 2019] Installing from online archive.
    [Fri Nov 29 15:42:34 CST 2019] Downloading https://github.com/Neilpang/acme.sh/archive/master.tar.gz
    [Fri Nov 29 15:42:35 CST 2019] Extracting master.tar.gz
    [Fri Nov 29 15:42:35 CST 2019] Installing to /root/.acme.sh
    [Fri Nov 29 15:42:35 CST 2019] Installed to /root/.acme.sh/acme.sh
    [Fri Nov 29 15:42:35 CST 2019] Installing alias to '/root/.bashrc'
    [Fri Nov 29 15:42:35 CST 2019] OK, Close and reopen your terminal to start using acme.sh
    [Fri Nov 29 15:42:35 CST 2019] Installing cron job
    37 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
    [Fri Nov 29 15:42:35 CST 2019] Good, bash is found, so change the shebang to use bash as preferred.
    [Fri Nov 29 15:42:36 CST 2019] OK
    [Fri Nov 29 15:42:36 CST 2019] Install success!
    

    我的报错

    [Fri Nov 29 15:15:47 CST 2019] It is recommended to install socat first.
    [Fri Nov 29 15:15:47 CST 2019] We use socat for standalone server if you use standalone mode.
    [Fri Nov 29 15:15:47 CST 2019] If you don't use standalone mode, just ignore this warning.
    

    如果安装报错,那么可能是因为系统缺少 acme.sh 所需要的依赖项,我的提示缺少socat
    安装socat
    apt install socat
    然后重新安装一遍 acme.sh

    2. 使用 acme.sh 生成证书

    停用NGINX(我使用的服务)
    以下的命令会临时监听 80 端口,请确保执行该命令前 80 端口没有使用。

    service nginx stop
    ~/.acme.sh/acme.sh --issue -d www.wanphp.com --standalone -k ec-256
    

    3. 安装证书和密钥

    ~/.acme.sh/acme.sh --installcert -d www.wanphp.com --fullchainpath /etc/ssl/wanphp.crt --keypath /etc/ssl/wanphp.key --ecc
    

    4.证书更新

    由于 Let's Encrypt 的证书有效期只有 3 个月,因此需要 90 天至少要更新一次证书,acme.sh 脚本会每 60 天自动更新证书。我使用定时更新(总是担心出问题)。
    更新脚本:/etc/ssl/updatessl.sh
    vi /etc/ssl/updatessl.sh

    #!/bin/bash
    echo "正在停止nginx容器ing..."
    service nginx stop
    #证书更新
    echo "正在更新证书ing..."
    ~/.acme.sh/acme.sh --renew -d www.wanphp.com --force --ecc
    ~/.acme.sh/acme.sh --installcert -d www.wanphp.com --fullchainpath /etc/ssl/wanphp.crt --keypath /etc/ssl/wanphp.key --ecc
    #启动nginx容器
    echo "正在启动nginx容器ing..."
    service nginx start
    

    添加执行权限
    chmod +x upssl.sh
    添加到crontab

    vi /etc/crontab
    #添加到crontab,每周执行一次(这下放心了)
    0  3    * * 1   root    /etc/ssl/updatessl.sh
    

    5.NGINX使用

    server {
      listen  443 ssl;
      ssl on;
      ssl_certificate       /etc/ssl/wanphp.crt;
      ssl_certificate_key   /etc/ssl/wanphp.key;
      ssl_protocols         TLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphers           HIGH:!aNULL:!MD5;
      server_name           www.wanphp.com;
            location /v2ray { 
                proxy_redirect off;
                proxy_pass http://127.0.0.1:10110;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header Host $http_host;
    
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            }
    }
    

    相关文章

      网友评论

          本文标题:https免费证书申请

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