mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-08 07:41:10 +08:00
【新增】【部署】百度云CDN
This commit is contained in:
@@ -6,11 +6,11 @@ import (
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
)
|
||||
|
||||
type ClientAliCas struct {
|
||||
type AliyunCasClient struct {
|
||||
aliyuncas.Client
|
||||
}
|
||||
|
||||
func NewClientAliCas(accessKey, accessSecret string) (_result *ClientAliCas, err error) {
|
||||
func ClientAliCas(accessKey, accessSecret string) (_result *AliyunCasClient, err error) {
|
||||
config := &openapi.Config{
|
||||
AccessKeyId: tea.String(accessKey),
|
||||
AccessKeySecret: tea.String(accessSecret),
|
||||
@@ -21,13 +21,13 @@ func NewClientAliCas(accessKey, accessSecret string) (_result *ClientAliCas, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := &ClientAliCas{
|
||||
client := &AliyunCasClient{
|
||||
Client: *casClient,
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func (c *ClientAliCas) UploadCert(certName, certContent, certKey string) (*int64, error) {
|
||||
func (c *AliyunCasClient) UploadCert(certName, certContent, certKey string) (*int64, error) {
|
||||
certificateRequest := &aliyuncas.UploadUserCertificateRequest{
|
||||
Cert: tea.String(certContent),
|
||||
Key: tea.String(certKey),
|
||||
|
||||
35
backend/internal/cert/deploy/client/baiduyun/baiduyunCdn.go
Normal file
35
backend/internal/cert/deploy/client/baiduyun/baiduyunCdn.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package baiduyun
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
baiduyuncdn "github.com/baidubce/bce-sdk-go/services/cdn"
|
||||
"github.com/baidubce/bce-sdk-go/services/cdn/api"
|
||||
)
|
||||
|
||||
type BaiduyunCdnClient struct {
|
||||
baiduyuncdn.Client
|
||||
}
|
||||
|
||||
func ClientBaiduCdn(ak, sk string) (*BaiduyunCdnClient, error) {
|
||||
client, err := baiduyuncdn.NewClient(ak, sk, "https://cdn.baidubce.com")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
baiduCdnClient := &BaiduyunCdnClient{
|
||||
Client: *client,
|
||||
}
|
||||
return baiduCdnClient, nil
|
||||
}
|
||||
|
||||
func (client *BaiduyunCdnClient) IPutCert(domain, certName, certContent, certKey string) (string, error) {
|
||||
certId, err := client.PutCert(domain, &api.UserCertificate{
|
||||
CertName: certName,
|
||||
ServerData: certContent,
|
||||
PrivateData: certKey,
|
||||
}, "ON")
|
||||
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("修改域名证书失败: %v", err)
|
||||
}
|
||||
return certId, nil
|
||||
}
|
||||
Reference in New Issue
Block a user