分类 默认分类 下的文章

自动验证域名
这个命令摘自proxySU的客户端自动申请更换证书,把域名解析到主机IP上,使用caddy会自动启动一个http服务为域名做域名验证,省去了自动配置网站的步骤,注意如果80端口被占用就要先停掉,适合没有web服务的服务器使用

acme.sh --force --debug --issue  --standalone  -d proxy2.xxx.com  --pre-hook "systemctl stop caddy"  --post-hook  "systemctl start caddy" --server letsencrypt

1. 安装 acme.sh
安装很简单, 一个命令:

curl https://get.acme.sh | sh -s email=my@example.com

普通用户和 root 用户都可以安装使用. 安装过程进行了以下几步:

把 acme.sh 安装到你的 home 目录下:

~/.acme.sh/

并创建 一个 shell 的 alias, 例如 .bashrc,方便你的使用: alias acme.sh=~/.acme.sh/acme.sh

自动为你创建 cronjob, 每天 0:00 点自动检测所有的证书, 如果快过期了, 需要更新, 则会自动更新证书.
更高级的安装选项请参考: https://github.com/Neilpang/acme.sh/wiki/How-to-install

安装过程不会污染已有的系统任何功能和文件, 所有的修改都限制在安装目录中: ~/.acme.sh/

中国大陆用户请参考:

https://github.com/acmesh-official/acme.sh/wiki/Install-in-China

以上链接说明内容如下:
如果你的安装服务器位于中国大陆境内, 访问 github 可能会不成功. 所以安装可能会失败.

推荐从这里下载安装:

#centos7.9系统,实操时报错:No such file or directory
https://gitee.com/neilpang/acme.sh

#从原仓库复制了一个20240120
https://e.coding.net/youxianbo/tools/acme.sh.git

安装步骤:
根据 How-to-install#3-or-git-clone-and-install

git clone https://gitee.com/neilpang/acme.sh.git
cd acme.sh
./acme.sh --install -m my@example.com
# 网站服务器上申请
#nginx配置
    #一键申请SSL证书验证目录相关设置
    location ~ \.well-known{
        default_type text/html;
        allow all;
    }
#申请命令
acme.sh --issue --webroot /home/wwwroot/xxx -d www.xxx.com,m.xxx.com

# 手动DNS申请
acme.sh --issue -d www.xxx.com,m.xxx.com --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please
#会报错,提示需要解析
#手动解析后再尝试执行命令,加上 --renew  参数
acme.sh --renew -d www.xxx.com,m.xxx.com --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please
#如果同时申请多个域名,--renew出现以下报错的话,可能需要改成单个域名才能找到申请的目录
#报错:
'm.xx.com,www.xx.com' is not an issued domain, skipping.
#换成单个域名(第一个域名,因为申请的时候key放到这个目录了m.xx.com_ecc/m.xx.com.key,renew的时候去m.xx.com,www.xx.com这个目录找,找不到文件)
acme.sh --renew -d m.xx.com --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please

检测网站证书

https://www.ssllabs.com/ssltest/index.html
https://myssl.com/dns_check.html#ssl_verify

./configure -prefix=/usr/local/php7 -with-config-file-path=/usr/local/php7/etc -with-mcrypt=/usr/include -enable-mysqlnd -with-gd -with-iconv -with-zlib -enable-bcmath -enable-shmop -enable-sysvsem -enable-inline-optimization -enable-mbregex -enable-fpm -enable-mbstring -enable-ftp -enable-gd-native-ttf -with-openssl -enable-pcntl -enable-sockets -with-xmlrpc -enable-zip -enable-soap -with-gettext -with-curl -with-jpeg-dir -with-freetype-dir -with-mysqli -enable-embedded-mysqli -with-pdo-mysql

https://segmentfault.com/q/1010000015379092

分析了几天,没有结果
很是蛋痛

今天终于找到问题原因:$data 变量中 存在一个同名的data的键,程序里并且进行了两次 extract($data),第一次把data中的数据导出后,就替换掉了 $data 导致第二次导出的数据就不存在了

问题是我其他有一个页面也用了data这个键名,也没有问题,就奇怪了

我开发环境,另一个页面也是存在 同键名的值 的,却没有问题


function arrayGet($array, $key, $default = null) {
    $keys = explode('.', $key);
    $a = $array;
    while (count($keys) != 0) {
        $key = array_shift($keys);
        if(!isset($a[$key])){
            return $default;
        }
        $a = $a[$key];
    }
    return $a;
}

function arraySet(&$array, $key, $value) {
    $keys = explode('.', $key);
    if (count($keys) == 1) {
        $array[$key] = $value;
        return;
    }
    $a = array();
    $b = $array;
    while (count($keys) != 0) {
        $k = array_shift($keys);
        $b = isset($b[$k]) ? $b[$k] : array();
        $a[$k] = $b;
    }
    $ka = array_keys($a);
    $a[end($ka)] = $value;
    for ($index = count($ka) - 2; $index >= 0; $index--) {
        $k = $ka[$index];
        $nextK = $ka[$index + 1];
        $a[$k] = array_merge($a[$k], array($nextK => $a[$nextK]));
    }
    $array[$ka[0]] = $a[$ka[0]];
}

parseQueryString(url) {
    let reg_url  = /^[^\?]+\?([\w\W]+)$/,
        reg_para = /([^&=]+)=([\w\W]*?)(&|$|#)/g,
        arr_url  = reg_url.exec(url),
        ret      = {},
        str_para, result;
    if (arr_url && arr_url[1]) {
        str_para = arr_url[1]
    } else {
        str_para = url
    }
    while ((result = reg_para.exec(str_para)) != null) {
        ret[result[1]] = result[2];
    }
    return ret;
},