mirror of
https://github.com/usual2970/certimate.git
synced 2025-10-04 13:34:52 +00:00
feat: new deployment provider: flexcdn
This commit is contained in:
@@ -40,6 +40,7 @@ import (
|
||||
pCdnfly "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/cdnfly"
|
||||
pDogeCDN "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/dogecloud-cdn"
|
||||
pEdgioApplications "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/edgio-applications"
|
||||
pFlexCDN "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/flexcdn"
|
||||
pGcoreCDN "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/gcore-cdn"
|
||||
pGoEdge "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/goedge"
|
||||
pHuaweiCloudCDN "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/huaweicloud-cdn"
|
||||
@@ -557,6 +558,25 @@ func createDeployerProvider(options *deployerProviderOptions) (deployer.Deployer
|
||||
return deployer, err
|
||||
}
|
||||
|
||||
case domain.DeploymentProviderTypeFlexCDN:
|
||||
{
|
||||
access := domain.AccessConfigForFlexCDN{}
|
||||
if err := maputil.Populate(options.ProviderAccessConfig, &access); err != nil {
|
||||
return nil, fmt.Errorf("failed to populate provider access config: %w", err)
|
||||
}
|
||||
|
||||
deployer, err := pFlexCDN.NewDeployer(&pFlexCDN.DeployerConfig{
|
||||
ApiUrl: access.ApiUrl,
|
||||
ApiRole: access.ApiRole,
|
||||
AccessKeyId: access.AccessKeyId,
|
||||
AccessKey: access.AccessKey,
|
||||
AllowInsecureConnections: access.AllowInsecureConnections,
|
||||
ResourceType: pFlexCDN.ResourceType(maputil.GetString(options.ProviderExtendedConfig, "resourceType")),
|
||||
CertificateId: maputil.GetInt64(options.ProviderExtendedConfig, "certificateId"),
|
||||
})
|
||||
return deployer, err
|
||||
}
|
||||
|
||||
case domain.DeploymentProviderTypeGcoreCDN:
|
||||
{
|
||||
access := domain.AccessConfigForGcore{}
|
||||
|
@@ -140,6 +140,14 @@ type AccessConfigForEmail struct {
|
||||
DefaultReceiverAddress string `json:"defaultReceiverAddress,omitempty"`
|
||||
}
|
||||
|
||||
type AccessConfigForFlexCDN struct {
|
||||
ApiUrl string `json:"apiUrl"`
|
||||
ApiRole string `json:"apiRole"`
|
||||
AccessKeyId string `json:"accessKeyId"`
|
||||
AccessKey string `json:"accessKey"`
|
||||
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
|
||||
}
|
||||
|
||||
type AccessConfigForGcore struct {
|
||||
ApiToken string `json:"apiToken"`
|
||||
}
|
||||
|
@@ -36,8 +36,8 @@ const (
|
||||
AccessProviderTypeDynv6 = AccessProviderType("dynv6")
|
||||
AccessProviderTypeEdgio = AccessProviderType("edgio")
|
||||
AccessProviderTypeEmail = AccessProviderType("email")
|
||||
AccessProviderTypeFastly = AccessProviderType("fastly") // Fastly(预留)
|
||||
AccessProviderTypeFlexCDN = AccessProviderType("flexcdn") // FlexCDN(预留)
|
||||
AccessProviderTypeFastly = AccessProviderType("fastly") // Fastly(预留)
|
||||
AccessProviderTypeFlexCDN = AccessProviderType("flexcdn")
|
||||
AccessProviderTypeGname = AccessProviderType("gname")
|
||||
AccessProviderTypeGcore = AccessProviderType("gcore")
|
||||
AccessProviderTypeGoDaddy = AccessProviderType("godaddy")
|
||||
@@ -196,7 +196,7 @@ const (
|
||||
DeploymentProviderTypeCdnfly = DeploymentProviderType(AccessProviderTypeCdnfly)
|
||||
DeploymentProviderTypeDogeCloudCDN = DeploymentProviderType(AccessProviderTypeDogeCloud + "-cdn")
|
||||
DeploymentProviderTypeEdgioApplications = DeploymentProviderType(AccessProviderTypeEdgio + "-applications")
|
||||
DeploymentProviderTypeFlexCDN = DeploymentProviderType(AccessProviderTypeFlexCDN) // FlexCDN(预留)
|
||||
DeploymentProviderTypeFlexCDN = DeploymentProviderType(AccessProviderTypeFlexCDN)
|
||||
DeploymentProviderTypeGcoreCDN = DeploymentProviderType(AccessProviderTypeGcore + "-cdn")
|
||||
DeploymentProviderTypeGoEdge = DeploymentProviderType(AccessProviderTypeGoEdge)
|
||||
DeploymentProviderTypeHuaweiCloudCDN = DeploymentProviderType(AccessProviderTypeHuaweiCloud + "-cdn")
|
||||
|
8
internal/pkg/core/deployer/providers/flexcdn/consts.go
Normal file
8
internal/pkg/core/deployer/providers/flexcdn/consts.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package flexcdn
|
||||
|
||||
type ResourceType string
|
||||
|
||||
const (
|
||||
// 资源类型:替换指定证书。
|
||||
RESOURCE_TYPE_CERTIFICATE = ResourceType("certificate")
|
||||
)
|
144
internal/pkg/core/deployer/providers/flexcdn/flexcdn.go
Normal file
144
internal/pkg/core/deployer/providers/flexcdn/flexcdn.go
Normal file
@@ -0,0 +1,144 @@
|
||||
package flexcdn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/usual2970/certimate/internal/pkg/core/deployer"
|
||||
flexcdnsdk "github.com/usual2970/certimate/internal/pkg/sdk3rd/flexcdn"
|
||||
certutil "github.com/usual2970/certimate/internal/pkg/utils/cert"
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
// FlexCDN URL。
|
||||
ApiUrl string `json:"apiUrl"`
|
||||
// FlexCDN 用户角色。
|
||||
ApiRole string `json:"apiRole"`
|
||||
// FlexCDN AccessKeyId。
|
||||
AccessKeyId string `json:"accessKeyId"`
|
||||
// FlexCDN AccessKey。
|
||||
AccessKey string `json:"accessKey"`
|
||||
// 是否允许不安全的连接。
|
||||
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
|
||||
// 部署资源类型。
|
||||
ResourceType ResourceType `json:"resourceType"`
|
||||
// 证书 ID。
|
||||
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
|
||||
CertificateId int64 `json:"certificateId,omitempty"`
|
||||
}
|
||||
|
||||
type DeployerProvider struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *flexcdnsdk.Client
|
||||
}
|
||||
|
||||
var _ deployer.Deployer = (*DeployerProvider)(nil)
|
||||
|
||||
func NewDeployer(config *DeployerConfig) (*DeployerProvider, error) {
|
||||
if config == nil {
|
||||
panic("config is nil")
|
||||
}
|
||||
|
||||
client, err := createSdkClient(config.ApiUrl, config.ApiRole, config.AccessKeyId, config.AccessKey, config.AllowInsecureConnections)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create sdk client: %w", err)
|
||||
}
|
||||
|
||||
return &DeployerProvider{
|
||||
config: config,
|
||||
logger: slog.Default(),
|
||||
sdkClient: client,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *DeployerProvider) WithLogger(logger *slog.Logger) deployer.Deployer {
|
||||
if logger == nil {
|
||||
d.logger = slog.Default()
|
||||
} else {
|
||||
d.logger = logger
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DeployerProvider) Deploy(ctx context.Context, certPEM string, privkeyPEM string) (*deployer.DeployResult, error) {
|
||||
// 根据部署资源类型决定部署方式
|
||||
switch d.config.ResourceType {
|
||||
case RESOURCE_TYPE_CERTIFICATE:
|
||||
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
|
||||
}
|
||||
|
||||
return &deployer.DeployResult{}, nil
|
||||
}
|
||||
|
||||
func (d *DeployerProvider) deployToCertificate(ctx context.Context, certPEM string, privkeyPEM string) error {
|
||||
if d.config.CertificateId == 0 {
|
||||
return errors.New("config `certificateId` is required")
|
||||
}
|
||||
|
||||
// 解析证书内容
|
||||
certX509, err := certutil.ParseCertificateFromPEM(certPEM)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 修改证书
|
||||
// REF: https://flexcdn.cloud/dev/api/service/SSLCertService?role=user#updateSSLCert
|
||||
updateSSLCertReq := &flexcdnsdk.UpdateSSLCertRequest{
|
||||
SSLCertId: d.config.CertificateId,
|
||||
IsOn: true,
|
||||
Name: fmt.Sprintf("certimate-%d", time.Now().UnixMilli()),
|
||||
Description: "upload from certimate",
|
||||
ServerName: certX509.Subject.CommonName,
|
||||
IsCA: false,
|
||||
CertData: base64.StdEncoding.EncodeToString([]byte(certPEM)),
|
||||
KeyData: base64.StdEncoding.EncodeToString([]byte(privkeyPEM)),
|
||||
TimeBeginAt: certX509.NotBefore.Unix(),
|
||||
TimeEndAt: certX509.NotAfter.Unix(),
|
||||
DNSNames: certX509.DNSNames,
|
||||
CommonNames: []string{certX509.Subject.CommonName},
|
||||
}
|
||||
updateSSLCertResp, err := d.sdkClient.UpdateSSLCert(updateSSLCertReq)
|
||||
d.logger.Debug("sdk request 'flexcdn.UpdateSSLCert'", slog.Any("request", updateSSLCertReq), slog.Any("response", updateSSLCertResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'flexcdn.UpdateSSLCert': %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSdkClient(apiUrl, apiRole, accessKeyId, accessKey string, skipTlsVerify bool) (*flexcdnsdk.Client, error) {
|
||||
if _, err := url.Parse(apiUrl); err != nil {
|
||||
return nil, errors.New("invalid flexcdn api url")
|
||||
}
|
||||
|
||||
if apiRole != "user" && apiRole != "admin" {
|
||||
return nil, errors.New("invalid flexcdn api role")
|
||||
}
|
||||
|
||||
if accessKeyId == "" {
|
||||
return nil, errors.New("invalid flexcdn access key id")
|
||||
}
|
||||
|
||||
if accessKey == "" {
|
||||
return nil, errors.New("invalid flexcdn access key")
|
||||
}
|
||||
|
||||
client := flexcdnsdk.NewClient(apiUrl, apiRole, accessKeyId, accessKey)
|
||||
if skipTlsVerify {
|
||||
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
83
internal/pkg/core/deployer/providers/flexcdn/flexcdn_test.go
Normal file
83
internal/pkg/core/deployer/providers/flexcdn/flexcdn_test.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package flexcdn_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/flexcdn"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fApiUrl string
|
||||
fAccessKeyId string
|
||||
fAccessKey string
|
||||
fCertificateId int
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "CERTIMATE_DEPLOYER_FLEXCDN_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fApiUrl, argsPrefix+"APIURL", "", "")
|
||||
flag.StringVar(&fAccessKeyId, argsPrefix+"ACCESSKEYID", "", "")
|
||||
flag.StringVar(&fAccessKey, argsPrefix+"ACCESSKEY", "", "")
|
||||
flag.IntVar(&fCertificateId, argsPrefix+"CERTIFICATEID", 0, "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./flexcdn_test.go -args \
|
||||
--CERTIMATE_DEPLOYER_FLEXCDN_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--CERTIMATE_DEPLOYER_FLEXCDN_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--CERTIMATE_DEPLOYER_FLEXCDN_APIURL="http://127.0.0.1:7788" \
|
||||
--CERTIMATE_DEPLOYER_FLEXCDN_ACCESSKEYID="your-access-key-id" \
|
||||
--CERTIMATE_DEPLOYER_FLEXCDN_ACCESSKEY="your-access-key" \
|
||||
--CERTIMATE_DEPLOYER_FLEXCDN_CERTIFICATEID="your-cerficiate-id"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("APIURL: %v", fApiUrl),
|
||||
fmt.Sprintf("ACCESSKEYID: %v", fAccessKeyId),
|
||||
fmt.Sprintf("ACCESSKEY: %v", fAccessKey),
|
||||
fmt.Sprintf("CERTIFICATEID: %v", fCertificateId),
|
||||
}, "\n"))
|
||||
|
||||
deployer, err := provider.NewDeployer(&provider.DeployerConfig{
|
||||
ApiUrl: fApiUrl,
|
||||
ApiRole: "user",
|
||||
AccessKeyId: fAccessKeyId,
|
||||
AccessKey: fAccessKey,
|
||||
AllowInsecureConnections: true,
|
||||
ResourceType: provider.RESOURCE_TYPE_CERTIFICATE,
|
||||
CertificateId: int64(fCertificateId),
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := deployer.Deploy(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
t.Logf("ok: %v", res)
|
||||
})
|
||||
}
|
@@ -58,6 +58,7 @@ func TestDeploy(t *testing.T) {
|
||||
|
||||
deployer, err := provider.NewDeployer(&provider.DeployerConfig{
|
||||
ApiUrl: fApiUrl,
|
||||
ApiRole: "user",
|
||||
AccessKeyId: fAccessKeyId,
|
||||
AccessKey: fAccessKey,
|
||||
AllowInsecureConnections: true,
|
||||
|
46
internal/pkg/sdk3rd/flexcdn/api.go
Normal file
46
internal/pkg/sdk3rd/flexcdn/api.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package flexcdn
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (c *Client) getAccessToken() error {
|
||||
req := &getAPIAccessTokenRequest{
|
||||
Type: c.apiRole,
|
||||
AccessKeyId: c.accessKeyId,
|
||||
AccessKey: c.accessKey,
|
||||
}
|
||||
res, err := c.sendRequest(http.MethodPost, "/APIAccessTokenService/getAPIAccessToken", req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp := &getAPIAccessTokenResponse{}
|
||||
if err := json.Unmarshal(res.Body(), &resp); err != nil {
|
||||
return fmt.Errorf("flexcdn api error: failed to unmarshal response: %w", err)
|
||||
} else if resp.GetCode() != 200 {
|
||||
return fmt.Errorf("flexcdn get access token failed: code: %d, message: %s", resp.GetCode(), resp.GetMessage())
|
||||
}
|
||||
|
||||
c.accessTokenMtx.Lock()
|
||||
c.accessToken = resp.Data.Token
|
||||
c.accessTokenExp = time.Unix(resp.Data.ExpiresAt, 0)
|
||||
c.accessTokenMtx.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) UpdateSSLCert(req *UpdateSSLCertRequest) (*UpdateSSLCertResponse, error) {
|
||||
if c.accessToken == "" || c.accessTokenExp.Before(time.Now()) {
|
||||
if err := c.getAccessToken(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
resp := &UpdateSSLCertResponse{}
|
||||
err := c.sendRequestWithResult(http.MethodPost, "/SSLCertService/updateSSLCert", req, resp)
|
||||
return resp, err
|
||||
}
|
103
internal/pkg/sdk3rd/flexcdn/client.go
Normal file
103
internal/pkg/sdk3rd/flexcdn/client.go
Normal file
@@ -0,0 +1,103 @@
|
||||
package flexcdn
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-resty/resty/v2"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
apiHost string
|
||||
apiRole string
|
||||
accessKeyId string
|
||||
accessKey string
|
||||
|
||||
accessToken string
|
||||
accessTokenExp time.Time
|
||||
accessTokenMtx sync.Mutex
|
||||
|
||||
client *resty.Client
|
||||
}
|
||||
|
||||
func NewClient(apiHost, apiRole, accessKeyId, accessKey string) *Client {
|
||||
client := resty.New()
|
||||
|
||||
return &Client{
|
||||
apiHost: strings.TrimRight(apiHost, "/"),
|
||||
apiRole: apiRole,
|
||||
accessKeyId: accessKeyId,
|
||||
accessKey: accessKey,
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) WithTimeout(timeout time.Duration) *Client {
|
||||
c.client.SetTimeout(timeout)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Client) WithTLSConfig(config *tls.Config) *Client {
|
||||
c.client.SetTLSClientConfig(config)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Client) sendRequest(method string, path string, params interface{}) (*resty.Response, error) {
|
||||
req := c.client.R().SetBasicAuth(c.accessKeyId, c.accessKey)
|
||||
req.Method = method
|
||||
req.URL = c.apiHost + path
|
||||
if strings.EqualFold(method, http.MethodGet) {
|
||||
qs := make(map[string]string)
|
||||
if params != nil {
|
||||
temp := make(map[string]any)
|
||||
jsonb, _ := json.Marshal(params)
|
||||
json.Unmarshal(jsonb, &temp)
|
||||
for k, v := range temp {
|
||||
if v != nil {
|
||||
qs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
req = req.
|
||||
SetHeader("X-Cloud-Access-Token", c.accessToken).
|
||||
SetQueryParams(qs)
|
||||
} else {
|
||||
req = req.
|
||||
SetHeader("Content-Type", "application/json").
|
||||
SetHeader("X-Cloud-Access-Token", c.accessToken).
|
||||
SetBody(params)
|
||||
}
|
||||
|
||||
resp, err := req.Send()
|
||||
if err != nil {
|
||||
return resp, fmt.Errorf("flexcdn api error: failed to send request: %w", err)
|
||||
} else if resp.IsError() {
|
||||
return resp, fmt.Errorf("flexcdn api error: unexpected status code: %d, resp: %s", resp.StatusCode(), resp.String())
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (c *Client) sendRequestWithResult(method string, path string, params interface{}, result BaseResponse) error {
|
||||
resp, err := c.sendRequest(method, path, params)
|
||||
if err != nil {
|
||||
if resp != nil {
|
||||
json.Unmarshal(resp.Body(), &result)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(resp.Body(), &result); err != nil {
|
||||
return fmt.Errorf("flexcdn api error: failed to unmarshal response: %w", err)
|
||||
} else if errcode := result.GetCode(); errcode != 200 {
|
||||
return fmt.Errorf("flexcdn api error: code='%d', message='%s'", errcode, result.GetMessage())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
52
internal/pkg/sdk3rd/flexcdn/models.go
Normal file
52
internal/pkg/sdk3rd/flexcdn/models.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package flexcdn
|
||||
|
||||
type BaseResponse interface {
|
||||
GetCode() int32
|
||||
GetMessage() string
|
||||
}
|
||||
|
||||
type baseResponse struct {
|
||||
Code int32 `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func (r *baseResponse) GetCode() int32 {
|
||||
return r.Code
|
||||
}
|
||||
|
||||
func (r *baseResponse) GetMessage() string {
|
||||
return r.Message
|
||||
}
|
||||
|
||||
type getAPIAccessTokenRequest struct {
|
||||
Type string `json:"type"`
|
||||
AccessKeyId string `json:"accessKeyId"`
|
||||
AccessKey string `json:"accessKey"`
|
||||
}
|
||||
|
||||
type getAPIAccessTokenResponse struct {
|
||||
baseResponse
|
||||
Data *struct {
|
||||
Token string `json:"token"`
|
||||
ExpiresAt int64 `json:"expiresAt"`
|
||||
} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateSSLCertRequest struct {
|
||||
SSLCertId int64 `json:"sslCertId"`
|
||||
IsOn bool `json:"isOn"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
ServerName string `json:"serverName"`
|
||||
IsCA bool `json:"isCA"`
|
||||
CertData string `json:"certData"`
|
||||
KeyData string `json:"keyData"`
|
||||
TimeBeginAt int64 `json:"timeBeginAt"`
|
||||
TimeEndAt int64 `json:"timeEndAt"`
|
||||
DNSNames []string `json:"dnsNames"`
|
||||
CommonNames []string `json:"commonNames"`
|
||||
}
|
||||
|
||||
type UpdateSSLCertResponse struct {
|
||||
baseResponse
|
||||
}
|
@@ -65,8 +65,8 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
|
||||
}
|
||||
|
||||
req = req.
|
||||
SetQueryParams(qs).
|
||||
SetHeader("X-Edge-Access-Token", c.accessToken)
|
||||
SetHeader("X-Edge-Access-Token", c.accessToken).
|
||||
SetQueryParams(qs)
|
||||
} else {
|
||||
req = req.
|
||||
SetHeader("Content-Type", "application/json").
|
||||
|
@@ -52,8 +52,8 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
|
||||
}
|
||||
|
||||
req = req.
|
||||
SetQueryParams(qs).
|
||||
SetHeader("Cookie", c.loginCookie)
|
||||
SetHeader("Cookie", c.loginCookie).
|
||||
SetQueryParams(qs)
|
||||
} else {
|
||||
req = req.
|
||||
SetHeader("Content-Type", "application/json").
|
||||
|
Reference in New Issue
Block a user