正在显示
1 个修改的文件
包含
52 行增加
和
0 行删除
| @@ -185,6 +185,48 @@ class DomainInfoLogic extends BaseLogic | @@ -185,6 +185,48 @@ class DomainInfoLogic extends BaseLogic | ||
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | /** | 187 | /** |
| 188 | + * 编辑amp网站证书 | ||
| 189 | + * @param $initDomain | ||
| 190 | + * @param $domain | ||
| 191 | + * @return array | ||
| 192 | + * @throws \App\Exceptions\AsideGlobalException | ||
| 193 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 194 | + * @author Akun | ||
| 195 | + * @date 2024/02/22 14:58 | ||
| 196 | + */ | ||
| 197 | + public function setAmpDomainSsl($initDomain,$domain) | ||
| 198 | + { | ||
| 199 | + if($this->param['amp_type'] == 2){ | ||
| 200 | + if(empty($this->param['amp_key'])){ | ||
| 201 | + $this->fail('AMP站点证书KEY值不能为空'); | ||
| 202 | + } | ||
| 203 | + if(empty($this->param['amp_cert'])){ | ||
| 204 | + $this->fail('AMP站点证书cert值不能为空'); | ||
| 205 | + } | ||
| 206 | + } | ||
| 207 | + $api_url = 'http://'.$initDomain.'/api/createSiteAmp'; | ||
| 208 | + $api_param = [ | ||
| 209 | + 'domain' => $domain, | ||
| 210 | + 'private_key' => $this->param['amp_key']??'', | ||
| 211 | + 'cert' => $this->param['amp_cert']??'' | ||
| 212 | + ]; | ||
| 213 | + | ||
| 214 | + try { | ||
| 215 | + $rs = HttpUtils::get($api_url, $api_param); | ||
| 216 | + $rs = json_decode($rs, true); | ||
| 217 | + if(isset($rs['status']) && $rs['status'] == 200){ | ||
| 218 | + return $this->success(); | ||
| 219 | + }else{ | ||
| 220 | + $this->fail($rs['message']??''); | ||
| 221 | + } | ||
| 222 | + } catch (\Exception | GuzzleException $e) { | ||
| 223 | + errorLog('创建AMP站点', $api_param, $e); | ||
| 224 | + $this->fail('编辑AMP站点证书失败'); | ||
| 225 | + } | ||
| 226 | + return $this->success(); | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + /** | ||
| 188 | * @remark :保存证书相关配置 | 230 | * @remark :保存证书相关配置 |
| 189 | * @name :sslSave | 231 | * @name :sslSave |
| 190 | * @author :lyh | 232 | * @author :lyh |
| @@ -225,10 +267,20 @@ class DomainInfoLogic extends BaseLogic | @@ -225,10 +267,20 @@ class DomainInfoLogic extends BaseLogic | ||
| 225 | 'type'=>$this->param['type'], | 267 | 'type'=>$this->param['type'], |
| 226 | 'private_key' => $this->param['key'] ?? '', | 268 | 'private_key' => $this->param['key'] ?? '', |
| 227 | 'private_cert' => $this->param['cert'] ?? '', | 269 | 'private_cert' => $this->param['cert'] ?? '', |
| 270 | + 'amp_status' => $this->param['amp_status'] ?? 0, | ||
| 271 | + 'amp_type' => $this->param['amp_type'] ?? 0, | ||
| 272 | + 'amp_private_key' => $this->param['amp_key'] ?? '', | ||
| 273 | + 'amp_private_cert' => $this->param['amp_cert'] ?? '', | ||
| 228 | ]; | 274 | ]; |
| 229 | $this->model->edit($data,['id'=>$this->param['id']]); | 275 | $this->model->edit($data,['id'=>$this->param['id']]); |
| 230 | //生成证书 | 276 | //生成证书 |
| 231 | $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? []); | 277 | $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? []); |
| 278 | + | ||
| 279 | + //amp站点生成证书 | ||
| 280 | + if($data['amp_status']){ | ||
| 281 | + $this->setAmpDomainSsl($server_info['init_domain'],$info['domain']); | ||
| 282 | + } | ||
| 283 | + | ||
| 232 | return $this->success(); | 284 | return $this->success(); |
| 233 | } | 285 | } |
| 234 | 286 |
-
请 注册 或 登录 后发表评论