mirror of
https://github.com/netcccyun/dnsmgr.git
synced 2026-02-21 15:31:12 +08:00
修复自动获取EAB
This commit is contained in:
parent
a1e4476603
commit
55272fd51b
@ -49,7 +49,7 @@ class CertHelper
|
||||
'wildcard' => true,
|
||||
'max_domains' => 100,
|
||||
'cname' => true,
|
||||
'note' => null,
|
||||
'note' => '<a href="https://app.zerossl.com/developer" target="_blank" rel="noreferrer">ZeroSSL密钥手动获取</a>',
|
||||
'inputs' => [
|
||||
'email' => [
|
||||
'name' => '邮箱地址',
|
||||
@ -57,6 +57,29 @@ class CertHelper
|
||||
'placeholder' => 'EAB申请邮箱',
|
||||
'required' => true,
|
||||
],
|
||||
'eabMode' => [
|
||||
'name' => 'EAB获取方式',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'auto' => '自动获取',
|
||||
'manual' => '手动输入',
|
||||
],
|
||||
'value' => 'manual'
|
||||
],
|
||||
'kid' => [
|
||||
'name' => 'EAB KID',
|
||||
'type' => 'input',
|
||||
'placeholder' => '',
|
||||
'required' => true,
|
||||
'show' => 'eabMode==\'manual\'',
|
||||
],
|
||||
'key' => [
|
||||
'name' => 'EAB HMAC Key',
|
||||
'type' => 'input',
|
||||
'placeholder' => '',
|
||||
'required' => true,
|
||||
'show' => 'eabMode==\'manual\'',
|
||||
],
|
||||
'proxy' => [
|
||||
'name' => '使用代理服务器',
|
||||
'type' => 'radio',
|
||||
@ -90,7 +113,7 @@ class CertHelper
|
||||
'auto' => '自动获取',
|
||||
'manual' => '手动输入',
|
||||
],
|
||||
'value' => 'auto'
|
||||
'value' => 'manual'
|
||||
],
|
||||
'kid' => [
|
||||
'name' => 'keyId',
|
||||
|
||||
@ -15,7 +15,7 @@ class customacme implements CertInterface
|
||||
public function __construct($config, $ext = null)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->ac = new ACMECert($config['directory'], $config['proxy'] == 1);
|
||||
$this->ac = new ACMECert($config['directory'], (int)$config['proxy']);
|
||||
if ($ext) {
|
||||
$this->ext = $ext;
|
||||
$this->ac->loadAccountKey($ext['key']);
|
||||
|
||||
@ -20,7 +20,7 @@ class letsencrypt implements CertInterface
|
||||
{
|
||||
$this->config = $config;
|
||||
if (empty($config['mode'])) $config['mode'] = 'live';
|
||||
$this->ac = new ACMECert($this->directories[$config['mode']], $config['proxy'] == 1);
|
||||
$this->ac = new ACMECert($this->directories[$config['mode']], (int)$config['proxy']);
|
||||
if ($ext) {
|
||||
$this->ext = $ext;
|
||||
$this->ac->loadAccountKey($ext['key']);
|
||||
|
||||
@ -16,7 +16,7 @@ class zerossl implements CertInterface
|
||||
public function __construct($config, $ext = null)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->ac = new ACMECert($this->directory, $config['proxy'] == 1);
|
||||
$this->ac = new ACMECert($this->directory, (int)$config['proxy']);
|
||||
if ($ext) {
|
||||
$this->ext = $ext;
|
||||
$this->ac->loadAccountKey($ext['key']);
|
||||
@ -27,7 +27,12 @@ class zerossl implements CertInterface
|
||||
public function register()
|
||||
{
|
||||
if (empty($this->config['email'])) throw new Exception('邮件地址不能为空');
|
||||
$eab = $this->getEAB($this->config['email']);
|
||||
|
||||
if (isset($this->config['eabMode']) && $this->config['eabMode'] == 'auto') {
|
||||
$eab = $this->getEAB($this->config['email']);
|
||||
} else {
|
||||
$eab = ['kid' => $this->config['kid'], 'key' => $this->config['key']];
|
||||
}
|
||||
|
||||
if (!empty($this->ext['key'])) {
|
||||
$kid = $this->ac->registerEAB(true, $eab['kid'], $eab['key'], $this->config['email']);
|
||||
@ -118,7 +123,7 @@ class zerossl implements CertInterface
|
||||
$response = curl_client($api, http_build_query(['email' => $email]), null, null, null, $this->config['proxy'] == 1);
|
||||
$result = json_decode($response['body'], true);
|
||||
if (!isset($result['success'])) {
|
||||
throw new Exception('解析返回数据失败:' . $response['body']);
|
||||
throw new Exception('获取EAB失败:' . $response['body']);
|
||||
} elseif (!$result['success'] && isset($result['error'])) {
|
||||
throw new Exception('获取EAB失败:' . $result['error']['code'] . ' - ' . $result['error']['type']);
|
||||
} elseif (!isset($result['eab_kid']) || !isset($result['eab_hmac_key'])) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user