mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-09 14:09:52 +00:00
Merge pull request #257 from belier-cn/main
feat: keep qiniu cdn https configuration
This commit is contained in:
commit
b458720dca
@ -59,7 +59,7 @@ func (d *QiniuCDNDeployer) Deploy(ctx context.Context) error {
|
|||||||
if domainInfo.Https != nil && domainInfo.Https.CertID != "" {
|
if domainInfo.Https != nil && domainInfo.Https.CertID != "" {
|
||||||
// 启用了 https
|
// 启用了 https
|
||||||
// 修改域名证书
|
// 修改域名证书
|
||||||
err = d.modifyDomainCert(certId)
|
err = d.modifyDomainCert(certId, domainInfo.Https.ForceHttps, domainInfo.Https.Http2Enable)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("modifyDomainCert failed: %w", err)
|
return fmt.Errorf("modifyDomainCert failed: %w", err)
|
||||||
}
|
}
|
||||||
@ -166,14 +166,14 @@ type qiniuModifyDomainCertReq struct {
|
|||||||
Http2Enable bool `json:"http2Enable"`
|
Http2Enable bool `json:"http2Enable"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *QiniuCDNDeployer) modifyDomainCert(certId string) error {
|
func (d *QiniuCDNDeployer) modifyDomainCert(certId string, forceHttps, http2Enable bool) error {
|
||||||
domain := d.option.DeployConfig.GetDomain()
|
domain := d.option.DeployConfig.GetDomain()
|
||||||
path := fmt.Sprintf("/domain/%s/httpsconf", domain)
|
path := fmt.Sprintf("/domain/%s/httpsconf", domain)
|
||||||
|
|
||||||
body := &qiniuModifyDomainCertReq{
|
body := &qiniuModifyDomainCertReq{
|
||||||
CertID: certId,
|
CertID: certId,
|
||||||
ForceHttps: true,
|
ForceHttps: forceHttps,
|
||||||
Http2Enable: true,
|
Http2Enable: http2Enable,
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyBytes, err := json.Marshal(body)
|
bodyBytes, err := json.Marshal(body)
|
||||||
|
@ -79,7 +79,7 @@ func Test_qiuniu_modifyDomainCert(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
q, _ := NewQiniuCDNDeployer(tt.fields.option)
|
q, _ := NewQiniuCDNDeployer(tt.fields.option)
|
||||||
if err := q.modifyDomainCert(tt.args.certId); (err != nil) != tt.wantErr {
|
if err := q.modifyDomainCert(tt.args.certId, true, true); (err != nil) != tt.wantErr {
|
||||||
t.Errorf("qiuniu.modifyDomainCert() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("qiuniu.modifyDomainCert() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user