|
@@ -38,7 +38,8 @@ type CdnService interface {
|
|
|
// 添加ssl策略
|
|
|
AddSSLPolicy(ctx context.Context, req v1.AddSSLPolicy) (int64, error)
|
|
|
DelSSLCert(ctx context.Context, sslCertId int64) error
|
|
|
- GetSSLPolicy(ctx context.Context, sslPolicyId int64) (v1.SSLPolicy, error)
|
|
|
+ EditSSLCert(ctx context.Context, req v1.SSlCert) error
|
|
|
+ EditSSLPolicy(ctx context.Context, req v1.SSLPolicy) error
|
|
|
}
|
|
|
|
|
|
func NewCdnService(
|
|
@@ -702,3 +703,63 @@ func (s *cdnService) GetSSLPolicy(ctx context.Context, sslPolicyId int64) (v1.SS
|
|
|
}
|
|
|
return res.Data, nil
|
|
|
}
|
|
|
+
|
|
|
+func (s *cdnService) EditSSLCert(ctx context.Context, req v1.SSlCert) error {
|
|
|
+ formData := map[string]interface{}{
|
|
|
+ "sslCertId": req.SslCertId,
|
|
|
+ "userId": req.UserId,
|
|
|
+ "isOn": req.IsOn,
|
|
|
+ "name": req.Name,
|
|
|
+ "description": req.Description,
|
|
|
+ "isCA": req.IsCA,
|
|
|
+ "certData": req.CertData,
|
|
|
+ "keyData": req.KeyData,
|
|
|
+ "timeBeginAt": req.TimeBeginAt,
|
|
|
+ "timeEndAt": req.TimeEndAt,
|
|
|
+ "dnsNames": req.DnsNames,
|
|
|
+ "commonNames": req.CommonNames,
|
|
|
+ "isSelfSigned": req.IsSelfSigned,
|
|
|
+ }
|
|
|
+ apiUrl := s.Url + "SSLCertService/createSSLCert"
|
|
|
+ resBody, err := s.sendDataWithTokenRetry(ctx, formData, apiUrl)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ var res v1.GeneralResponse[any]
|
|
|
+ if err := json.Unmarshal(resBody, &res); err != nil {
|
|
|
+ return fmt.Errorf("反序列化响应 JSON 失败 (内容: %s): %w", string(resBody), err)
|
|
|
+ }
|
|
|
+ if res.Code != 200 {
|
|
|
+ return fmt.Errorf("API 错误: code %d, msg '%s'", res.Code, res.Message)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (s *cdnService) EditSSLPolicy(ctx context.Context, req v1.SSLPolicy) error {
|
|
|
+ formData := map[string]interface{}{
|
|
|
+ "sslPolicyId": req.SslPolicyId,
|
|
|
+ "http2Enabled": req.Http2Enabled,
|
|
|
+ "http3Enabled": req.Http3Enabled,
|
|
|
+ "minVersion": req.MinVersion,
|
|
|
+ "sslCertsJSON": req.SslCertsJSON,
|
|
|
+ "hstsJSON": req.HstsJSON,
|
|
|
+ "clientAuthType": req.ClientAuthType,
|
|
|
+ "cipherSuites": req.CipherSuites,
|
|
|
+ "cipherSuitesIsOn": req.CipherSuitesIsOn,
|
|
|
+ }
|
|
|
+ apiUrl := s.Url + "SSLPolicyService/updateSSLPolicy"
|
|
|
+ resBody, err := s.sendDataWithTokenRetry(ctx, formData, apiUrl)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ var res v1.GeneralResponse[any]
|
|
|
+ if err := json.Unmarshal(resBody, &res); err != nil {
|
|
|
+ return fmt.Errorf("反序列化响应 JSON 失败 (内容: %s): %w", string(resBody), err)
|
|
|
+ }
|
|
|
+ if res.Code != 200 {
|
|
|
+ return fmt.Errorf("API 错误: code %d, msg '%s'", res.Code, res.Message)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+
|
|
|
+}
|