mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-14 10:22:02 +08:00
【新增】【部署】百度云CDN
This commit is contained in:
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