mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-13 18:10:53 +08:00
插件示例-阿里云
This commit is contained in:
31
plugins/aliyun/cas/action.go
Normal file
31
plugins/aliyun/cas/action.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package cas
|
||||
|
||||
import (
|
||||
cas "github.com/alibabacloud-go/cas-20200407/v4/client"
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
util "github.com/alibabacloud-go/tea-utils/v2/service"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
)
|
||||
|
||||
func CreateClient(accessKey, accessSecret, endpoint string) (*cas.Client, error) {
|
||||
if endpoint == "" {
|
||||
endpoint = "cas.ap-southeast-1.aliyuncs.com"
|
||||
}
|
||||
config := &openapi.Config{
|
||||
AccessKeyId: tea.String(accessKey),
|
||||
AccessKeySecret: tea.String(accessSecret),
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
return cas.NewClient(config)
|
||||
}
|
||||
|
||||
func UploadToCas(client *cas.Client, cert, key, name string) error {
|
||||
uploadUserCertificateRequest := &cas.UploadUserCertificateRequest{
|
||||
Name: tea.String(name),
|
||||
Cert: tea.String(cert),
|
||||
Key: tea.String(key),
|
||||
}
|
||||
runtime := &util.RuntimeOptions{}
|
||||
_, err := client.UploadUserCertificateWithOptions(uploadUserCertificateRequest, runtime)
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user