Skip to content

Commit 1228e7d

Browse files
tongyimingmikatong
andauthored
ssl_pay_certificate support confirm_letter and dv_auths (#1472)
* ssl_pay_certificate support confirm_letter and dv_auths * add changelog Co-authored-by: mikatong <mikatong@tencent.com>
1 parent b1a0932 commit 1228e7d

File tree

6 files changed

+126
-12
lines changed

6 files changed

+126
-12
lines changed

.changelog/1472.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_ssl_pay_certificate: update the `product_id` value, support `confirm_letter` and `dv_auths`
3+
```

tencentcloud/extension_ssl.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,19 @@ var SSL_CERT_TYPE = []string{
4646
SSL_CERT_TYPE_SERVER,
4747
SSL_CERT_TYPE_CA,
4848
}
49+
var DNSPOD_OV_EV_TYPE = []int64{51, 52, 53}
50+
var GEOTRUST_OV_EV_TYPE = []int64{8, 9, 10}
51+
var SECURESITE_OV_EV_TYPE = []int64{3, 4, 5, 6, 7}
52+
var TRUSTASIA_OV_EV_TYPE = []int64{13, 14, 15, 16, 17}
53+
var GLOBALSIGN_OV_EV_TYPE = []int64{18, 19, 20, 21, 22, 23, 24}
54+
55+
func IsContainProductId(productId int64, lists ...[]int64) bool {
56+
for _, list := range lists {
57+
for _, item := range list {
58+
if item == productId {
59+
return true
60+
}
61+
}
62+
}
63+
return false
64+
}

tencentcloud/resource_tc_ssl_pay_certificate.go

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ func resourceTencentCloudSSLInstance() *schema.Resource {
8181
Type: schema.TypeInt,
8282
Required: true,
8383
ForceNew: true,
84-
ValidateFunc: validateIntegerInRange(3, 42),
85-
Description: "Certificate commodity ID. Valid value ranges: (3~42). `3` means SecureSite Enhanced Enterprise Edition (EV Pro), " +
86-
"`4` means SecureSite Enhanced (EV), `5` means SecureSite Enterprise Professional Edition (OV Pro), " +
84+
ValidateFunc: validateIntegerInRange(3, 56),
85+
Description: "Certificate commodity ID. Valid value ranges: (3~42). `3` means SecureSite enhanced Enterprise Edition (EV Pro), " +
86+
"`4` means SecureSite enhanced (EV), `5` means SecureSite Enterprise Professional Edition (OV Pro), " +
8787
"`6` means SecureSite Enterprise (OV), `7` means SecureSite Enterprise Type (OV) wildcard, " +
8888
"`8` means Geotrust enhanced (EV), `9` means Geotrust enterprise (OV), " +
8989
"`10` means Geotrust enterprise (OV) wildcard, `11` means TrustAsia domain type multi-domain SSL certificate, " +
@@ -97,11 +97,18 @@ func resourceTencentCloudSSLInstance() *schema.Resource {
9797
"`26` means Wotrus domain type multi-domain certificate, `27` means Wotrus domain type wildcard certificate, " +
9898
"`28` means Wotrus enterprise type certificate, `29` means Wotrus enterprise multi-domain certificate, " +
9999
"`30` means Wotrus enterprise wildcard certificate, `31` means Wotrus enhanced certificate, " +
100-
"`32` means Wotrus enhanced multi-domain certificate, `33` means DNSPod national secret domain name certificate, " +
101-
"`34` means DNSPod national secret domain name certificate Multi-domain certificate, `35` means DNSPod national secret domain name wildcard certificate, " +
102-
"`37` means DNSPod national secret enterprise certificate, `38` means DNSPod national secret enterprise multi-domain certificate, " +
103-
"`39` means DNSPod national secret enterprise wildcard certificate, `40` means DNSPod national secret increase Strong certificate, " +
104-
"`41` means DNSPod national secret enhanced multi-domain certificate, `42` means TrustAsia domain-type wildcard multi-domain certificate.",
100+
"`32` means Wotrus enhanced multi-domain certificate, `33` means WoTrus National Secret Domain name Certificate, " +
101+
"`34` means WoTrus National Secret Domain name Certificate (multiple domain names), `35` WoTrus National Secret Domain name Certificate (wildcard), " +
102+
"`37` means WoTrus State Secret Enterprise Certificate, `38` means WoTrus State Secret Enterprise Certificate (multiple domain names), " +
103+
"`39` means WoTrus State Secret Enterprise Certificate (wildcard), `40` means WoTrus National secret enhanced certificate, " +
104+
"`41` means WoTrus National Secret enhanced Certificate (multiple domain names), `42` means TrustAsia- Domain name Certificate (wildcard multiple domain names), " +
105+
"`43` means DNSPod Enterprise (OV) SSL Certificate, `44` means DNSPod- Enterprise (OV) wildcard SSL certificate, " +
106+
"`45` means DNSPod Enterprise (OV) Multi-domain name SSL Certificate, `46` means DNSPod enhanced (EV) SSL certificate, " +
107+
"`47` means DNSPod enhanced (EV) multi-domain name SSL certificate, `48` means DNSPod Domain name Type (DV) SSL Certificate, " +
108+
"`49` means DNSPod Domain name Type (DV) wildcard SSL certificate, `50` means DNSPod domain name type (DV) multi-domain name SSL certificate, " +
109+
"`51` means DNSPod (State Secret) Enterprise (OV) SSL certificate, `52` DNSPod (National Secret) Enterprise (OV) wildcard SSL certificate, " +
110+
"`53` means DNSPod (National Secret) Enterprise (OV) multi-domain SSL certificate, `54` means DNSPod (National Secret) Domain Name (DV) SSL certificate, " +
111+
"`55` means DNSPod (National Secret) Domain Name Type (DV) wildcard SSL certificate, `56` means DNSPod (National Secret) Domain Name Type (DV) multi-domain SSL certificate.",
105112
},
106113
"domain_num": {
107114
Type: schema.TypeInt,
@@ -127,6 +134,11 @@ func resourceTencentCloudSSLInstance() *schema.Resource {
127134
Computed: true,
128135
Description: "Remark name.",
129136
},
137+
"confirm_letter": {
138+
Type: schema.TypeString,
139+
Optional: true,
140+
Description: "The base64-encoded certificate confirmation file should be in jpg, jpeg, png, pdf, and the size should be between 1kb and 1.4M. Note: it only works when product_id is set to 8, 9 or 10.",
141+
},
130142
// ssl information
131143
"information": {
132144
Type: schema.TypeList,
@@ -313,6 +325,30 @@ func resourceTencentCloudSSLInstance() *schema.Resource {
313325
Computed: true,
314326
Description: "SSL certificate status.",
315327
},
328+
"dv_auths": {
329+
Type: schema.TypeList,
330+
Computed: true,
331+
Description: "DV certification information.",
332+
Elem: &schema.Resource{
333+
Schema: map[string]*schema.Schema{
334+
"dv_auth_key": {
335+
Type: schema.TypeString,
336+
Computed: true,
337+
Description: "DV authentication key.",
338+
},
339+
"dv_auth_value": {
340+
Type: schema.TypeString,
341+
Computed: true,
342+
Description: "DV authentication value.",
343+
},
344+
"dv_auth_verify_type": {
345+
Type: schema.TypeString,
346+
Computed: true,
347+
Description: "DV authentication type.",
348+
},
349+
},
350+
},
351+
},
316352
},
317353
}
318354
}
@@ -321,6 +357,7 @@ func resourceTencentCloudSSLInstanceCreate(d *schema.ResourceData, meta interfac
321357
defer logElapsed("resource.tencentcloud_ssl_pay_certificate.create")()
322358

323359
var (
360+
productId = int64(d.Get("product_id").(int))
324361
logId = getLogId(contextNil)
325362
ctx = context.WithValue(context.TODO(), logIdKey, logId)
326363
sslService = SSLService{client: meta.(*TencentCloudClient).apiV3Conn}
@@ -329,7 +366,7 @@ func resourceTencentCloudSSLInstanceCreate(d *schema.ResourceData, meta interfac
329366
)
330367

331368
request := ssl.NewCreateCertificateRequest()
332-
request.ProductId = helper.Int64(int64(d.Get("product_id").(int)))
369+
request.ProductId = helper.Int64(productId)
333370
request.DomainNum = helper.Int64(int64(d.Get("domain_num").(int)))
334371
request.TimeSpan = helper.Int64(int64(d.Get("time_span").(int)))
335372

@@ -430,6 +467,27 @@ func resourceTencentCloudSSLInstanceCreate(d *schema.ResourceData, meta interfac
430467
return err
431468
}
432469

470+
if IsContainProductId(productId, GEOTRUST_OV_EV_TYPE) {
471+
confirmLetter := d.Get("confirm_letter").(string)
472+
uploadConfirmLetterRequest := ssl.NewUploadConfirmLetterRequest()
473+
uploadConfirmLetterRequest.CertificateId = helper.String(certificateId)
474+
uploadConfirmLetterRequest.ConfirmLetter = helper.String(confirmLetter)
475+
if err = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
476+
if err = sslService.UploadConfirmLetter(ctx, uploadConfirmLetterRequest); err != nil {
477+
if sdkError, ok := err.(*errors.TencentCloudSDKError); ok {
478+
code := sdkError.GetCode()
479+
if code == InvalidParam || code == CertificateNotFound {
480+
return resource.NonRetryableError(sdkError)
481+
}
482+
}
483+
return retryError(err)
484+
}
485+
return nil
486+
}); err != nil {
487+
return err
488+
}
489+
}
490+
433491
return resourceTencentCloudSSLInstanceRead(d, meta)
434492
}
435493

@@ -497,6 +555,18 @@ func resourceTencentCloudSSLInstanceRead(d *schema.ResourceData, meta interface{
497555
if response.Response.SubmittedData != nil {
498556
setSubmitInfo(d, response.Response.SubmittedData)
499557
}
558+
if response.Response.DvAuthDetail != nil && len(response.Response.DvAuthDetail.DvAuths) != 0 {
559+
dvAuths := make([]map[string]string, 0)
560+
for _, item := range response.Response.DvAuthDetail.DvAuths {
561+
dvAuth := make(map[string]string)
562+
dvAuth["dv_auth_key"] = *item.DvAuthKey
563+
dvAuth["dv_auth_value"] = *item.DvAuthValue
564+
dvAuth["dv_auth_verify_type"] = *item.DvAuthVerifyType
565+
dvAuths = append(dvAuths, dvAuth)
566+
}
567+
568+
_ = d.Set("dv_auths", dvAuths)
569+
}
500570

501571
return nil
502572
}
@@ -651,7 +721,7 @@ func getSubmitInfoRequest(d *schema.ResourceData) *ssl.SubmitCertificateInformat
651721

652722
func setSubmitInfo(d *schema.ResourceData, info *ssl.SubmittedData) {
653723
infos := make([]map[string]interface{}, 1)
654-
infos[1] = map[string]interface{}{
724+
infos[0] = map[string]interface{}{
655725
"csr_type": info.CsrType,
656726
"organization_name": info.OrganizationName,
657727
"organization_division": info.OrganizationDivision,

tencentcloud/resource_tc_ssl_pay_certificate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestAccTencentCloudSSLInstance(t *testing.T) {
1818
t.Parallel()
1919

2020
resource.Test(t, resource.TestCase{
21-
PreCheck: func() { testAccPreCheck(t) },
21+
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
2222
Providers: testAccProviders,
2323
CheckDestroy: testAccCheckSSLInstanceDestroy,
2424
Steps: []resource.TestStep{

tencentcloud/service_tencent_ssl_certificate.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,26 @@ func (me *SSLService) SubmitCertificateInformation(ctx context.Context, request
212212
return
213213
}
214214

215+
func (me *SSLService) UploadConfirmLetter(ctx context.Context, request *ssl.UploadConfirmLetterRequest) (err error) {
216+
logId := getLogId(ctx)
217+
client := me.client.UseSSLCertificateClient()
218+
ratelimit.Check(request.GetAction())
219+
220+
var response *ssl.UploadConfirmLetterResponse
221+
222+
response, err = client.UploadConfirmLetter(request)
223+
if err != nil {
224+
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
225+
logId, request.GetAction(), request.ToJsonString(), err.Error())
226+
return
227+
}
228+
if response == nil || response.Response == nil {
229+
err = fmt.Errorf("TencentCloud SDK %s return empty response", request.GetAction())
230+
return
231+
}
232+
return
233+
}
234+
215235
func (me *SSLService) UploadCertificate(ctx context.Context, request *ssl.UploadCertificateRequest) (id string, err error) {
216236
logId := getLogId(ctx)
217237
client := me.client.UseSSLCertificateClient()

website/docs/r/ssl_pay_certificate.html.markdown

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ The following arguments are supported:
5858

5959
* `domain_num` - (Required, Int, ForceNew) Number of domain names included in the certificate.
6060
* `information` - (Required, List, ForceNew) Certificate information.
61-
* `product_id` - (Required, Int, ForceNew) Certificate commodity ID. Valid value ranges: (3~42). `3` means SecureSite Enhanced Enterprise Edition (EV Pro), `4` means SecureSite Enhanced (EV), `5` means SecureSite Enterprise Professional Edition (OV Pro), `6` means SecureSite Enterprise (OV), `7` means SecureSite Enterprise Type (OV) wildcard, `8` means Geotrust enhanced (EV), `9` means Geotrust enterprise (OV), `10` means Geotrust enterprise (OV) wildcard, `11` means TrustAsia domain type multi-domain SSL certificate, `12` means TrustAsia domain type ( DV) wildcard, `13` means TrustAsia enterprise wildcard (OV) SSL certificate (D3), `14` means TrustAsia enterprise (OV) SSL certificate (D3), `15` means TrustAsia enterprise multi-domain (OV) SSL certificate (D3), `16` means TrustAsia Enhanced (EV) SSL Certificate (D3), `17` means TrustAsia Enhanced Multiple Domain (EV) SSL Certificate (D3), `18` means GlobalSign Enterprise (OV) SSL Certificate, `19` means GlobalSign Enterprise Wildcard (OV) SSL Certificate, `20` means GlobalSign Enhanced (EV) SSL Certificate, `21` means TrustAsia Enterprise Wildcard Multiple Domain (OV) SSL Certificate (D3), `22` means GlobalSign Enterprise Multiple Domain (OV) SSL Certificate, `23` means GlobalSign Enterprise Multiple Wildcard Domain name (OV) SSL certificate, `24` means GlobalSign enhanced multi-domain (EV) SSL certificate, `25` means Wotrus domain type certificate, `26` means Wotrus domain type multi-domain certificate, `27` means Wotrus domain type wildcard certificate, `28` means Wotrus enterprise type certificate, `29` means Wotrus enterprise multi-domain certificate, `30` means Wotrus enterprise wildcard certificate, `31` means Wotrus enhanced certificate, `32` means Wotrus enhanced multi-domain certificate, `33` means DNSPod national secret domain name certificate, `34` means DNSPod national secret domain name certificate Multi-domain certificate, `35` means DNSPod national secret domain name wildcard certificate, `37` means DNSPod national secret enterprise certificate, `38` means DNSPod national secret enterprise multi-domain certificate, `39` means DNSPod national secret enterprise wildcard certificate, `40` means DNSPod national secret increase Strong certificate, `41` means DNSPod national secret enhanced multi-domain certificate, `42` means TrustAsia domain-type wildcard multi-domain certificate.
61+
* `product_id` - (Required, Int, ForceNew) Certificate commodity ID. Valid value ranges: (3~42). `3` means SecureSite enhanced Enterprise Edition (EV Pro), `4` means SecureSite enhanced (EV), `5` means SecureSite Enterprise Professional Edition (OV Pro), `6` means SecureSite Enterprise (OV), `7` means SecureSite Enterprise Type (OV) wildcard, `8` means Geotrust enhanced (EV), `9` means Geotrust enterprise (OV), `10` means Geotrust enterprise (OV) wildcard, `11` means TrustAsia domain type multi-domain SSL certificate, `12` means TrustAsia domain type ( DV) wildcard, `13` means TrustAsia enterprise wildcard (OV) SSL certificate (D3), `14` means TrustAsia enterprise (OV) SSL certificate (D3), `15` means TrustAsia enterprise multi-domain (OV) SSL certificate (D3), `16` means TrustAsia Enhanced (EV) SSL Certificate (D3), `17` means TrustAsia Enhanced Multiple Domain (EV) SSL Certificate (D3), `18` means GlobalSign Enterprise (OV) SSL Certificate, `19` means GlobalSign Enterprise Wildcard (OV) SSL Certificate, `20` means GlobalSign Enhanced (EV) SSL Certificate, `21` means TrustAsia Enterprise Wildcard Multiple Domain (OV) SSL Certificate (D3), `22` means GlobalSign Enterprise Multiple Domain (OV) SSL Certificate, `23` means GlobalSign Enterprise Multiple Wildcard Domain name (OV) SSL certificate, `24` means GlobalSign enhanced multi-domain (EV) SSL certificate, `25` means Wotrus domain type certificate, `26` means Wotrus domain type multi-domain certificate, `27` means Wotrus domain type wildcard certificate, `28` means Wotrus enterprise type certificate, `29` means Wotrus enterprise multi-domain certificate, `30` means Wotrus enterprise wildcard certificate, `31` means Wotrus enhanced certificate, `32` means Wotrus enhanced multi-domain certificate, `33` means WoTrus National Secret Domain name Certificate, `34` means WoTrus National Secret Domain name Certificate (multiple domain names), `35` WoTrus National Secret Domain name Certificate (wildcard), `37` means WoTrus State Secret Enterprise Certificate, `38` means WoTrus State Secret Enterprise Certificate (multiple domain names), `39` means WoTrus State Secret Enterprise Certificate (wildcard), `40` means WoTrus National secret enhanced certificate, `41` means WoTrus National Secret enhanced Certificate (multiple domain names), `42` means TrustAsia- Domain name Certificate (wildcard multiple domain names), `43` means DNSPod Enterprise (OV) SSL Certificate, `44` means DNSPod- Enterprise (OV) wildcard SSL certificate, `45` means DNSPod Enterprise (OV) Multi-domain name SSL Certificate, `46` means DNSPod enhanced (EV) SSL certificate, `47` means DNSPod enhanced (EV) multi-domain name SSL certificate, `48` means DNSPod Domain name Type (DV) SSL Certificate, `49` means DNSPod Domain name Type (DV) wildcard SSL certificate, `50` means DNSPod domain name type (DV) multi-domain name SSL certificate, `51` means DNSPod (State Secret) Enterprise (OV) SSL certificate, `52` DNSPod (National Secret) Enterprise (OV) wildcard SSL certificate, `53` means DNSPod (National Secret) Enterprise (OV) multi-domain SSL certificate, `54` means DNSPod (National Secret) Domain Name (DV) SSL certificate, `55` means DNSPod (National Secret) Domain Name Type (DV) wildcard SSL certificate, `56` means DNSPod (National Secret) Domain Name Type (DV) multi-domain SSL certificate.
6262
* `alias` - (Optional, String) Remark name.
63+
* `confirm_letter` - (Optional, String) The base64-encoded certificate confirmation file should be in jpg, jpeg, png, pdf, and the size should be between 1kb and 1.4M. Note: it only works when product_id is set to 8, 9 or 10.
6364
* `project_id` - (Optional, Int) The ID of project.
6465
* `time_span` - (Optional, Int) Certificate period, currently only supports 1 year certificate purchase.
6566

@@ -97,6 +98,10 @@ In addition to all arguments above, the following attributes are exported:
9798

9899
* `id` - ID of the resource.
99100
* `certificate_id` - Returned certificate ID.
101+
* `dv_auths` - DV certification information.
102+
* `dv_auth_key` - DV authentication key.
103+
* `dv_auth_value` - DV authentication value.
104+
* `dv_auth_verify_type` - DV authentication type.
100105
* `order_id` - Order ID returned.
101106
* `status` - SSL certificate status.
102107

0 commit comments

Comments
 (0)