mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-18 04:02:02 +08:00
【调整】插件支持动态参数和参数类型
【调整】获取证书列表支持状态过滤 【新增】dns提供商腾讯云eo
This commit is contained in:
54
plugins/alicloud/waf/action.go
Normal file
54
plugins/alicloud/waf/action.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package waf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Deploy(cfg map[string]any) error {
|
||||
certPEM, ok := cfg["cert"].(string)
|
||||
if !ok || certPEM == "" {
|
||||
return fmt.Errorf("证书错误:cert")
|
||||
}
|
||||
keyPEM, ok := cfg["key"].(string)
|
||||
if !ok || keyPEM == "" {
|
||||
return fmt.Errorf("证书错误:key")
|
||||
}
|
||||
accessKey, ok := cfg["access_key_id"].(string)
|
||||
if !ok || accessKey == "" {
|
||||
return fmt.Errorf("参数错误:access_key_id")
|
||||
}
|
||||
accessSecret, ok := cfg["access_key_secret"].(string)
|
||||
if !ok || accessSecret == "" {
|
||||
return fmt.Errorf("参数错误:access_key_secret")
|
||||
}
|
||||
region, ok := cfg["region"].(string)
|
||||
if !ok || region == "" {
|
||||
return fmt.Errorf("参数错误:region")
|
||||
}
|
||||
domain, ok := cfg["domain"].(string)
|
||||
if !ok || domain == "" {
|
||||
return fmt.Errorf("参数错误:domain")
|
||||
}
|
||||
client, err := ClientAliWaf(accessKey, accessSecret, region)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
instanceId, err := client.IGetInstanceId()
|
||||
if err != nil {
|
||||
return fmt.Errorf("获取地区实例ID失败: %v", err)
|
||||
}
|
||||
domainDesc, err := client.IDescribeDomainDetail(*instanceId, domain)
|
||||
if err != nil {
|
||||
return fmt.Errorf("获取域名配置详情失败: %v", err)
|
||||
}
|
||||
certName := fmt.Sprintf("%s_allinssl_%d", domain, time.Now().UnixMilli())
|
||||
certId, err := client.ICreateCerts(certName, certPEM, keyPEM, *instanceId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("创建证书失败: %v", err)
|
||||
}
|
||||
if err := client.IUpdateDomain(domainDesc, *instanceId, *certId); err != nil {
|
||||
return fmt.Errorf("更新证书失败: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user