@@ -40,8 +40,37 @@ func ResourceSystemCertificate() *schema.Resource {
40
40
resSchema := map [string ]* schema.Schema {
41
41
MetaResourcePath : PropResourcePath ("/certificate" ),
42
42
MetaId : PropId (Id ),
43
- MetaSkipFields : PropSkipFields ("import" , "sign" , "sign_via_scep" ),
43
+ MetaSkipFields : PropSkipFields ("acme_ssl_certificate" , " import" , "sign" , "sign_via_scep" ),
44
44
45
+ "acme_ssl_certificate" : {
46
+ Type : schema .TypeSet ,
47
+ Optional : true ,
48
+ ForceNew : true ,
49
+ Description : "Enable SSL certificate. This will generate a new certificate using ACME protocol." ,
50
+ ConflictsWith : []string {"import" , "sign" , "sign_via_scep" },
51
+ Elem : & schema.Resource {
52
+ Schema : map [string ]* schema.Schema {
53
+ "directory_url" : {
54
+ Type : schema .TypeString ,
55
+ Optional : true ,
56
+ Description : "ACME directory url." ,
57
+ DiffSuppressFunc : AlwaysPresentNotUserProvided ,
58
+ },
59
+ "eab_hmac_key" : {
60
+ Type : schema .TypeString ,
61
+ Optional : true ,
62
+ Description : "HMAC key for ACME External Account Binding (optional)." ,
63
+ DiffSuppressFunc : AlwaysPresentNotUserProvided ,
64
+ },
65
+ "eab_kid" : {
66
+ Type : schema .TypeString ,
67
+ Optional : true ,
68
+ Description : "Key identifier." ,
69
+ DiffSuppressFunc : AlwaysPresentNotUserProvided ,
70
+ },
71
+ },
72
+ },
73
+ },
45
74
"authority" : {
46
75
Type : schema .TypeString ,
47
76
Computed : true ,
@@ -126,7 +155,7 @@ func ResourceSystemCertificate() *schema.Resource {
126
155
Type : schema .TypeSet ,
127
156
Optional : true ,
128
157
ForceNew : true ,
129
- ConflictsWith : []string {"sign" , "sign_via_scep" },
158
+ ConflictsWith : []string {"acme_ssl_certificate" , " sign" , "sign_via_scep" },
130
159
Elem : & schema.Resource {
131
160
Schema : map [string ]* schema.Schema {
132
161
"cert_file_name" : {
@@ -249,7 +278,7 @@ func ResourceSystemCertificate() *schema.Resource {
249
278
Type : schema .TypeSet ,
250
279
Optional : true ,
251
280
ForceNew : true ,
252
- ConflictsWith : []string {"sign_via_scep" },
281
+ ConflictsWith : []string {"acme_ssl_certificate" , " sign_via_scep" },
253
282
Elem : & schema.Resource {
254
283
Schema : map [string ]* schema.Schema {
255
284
"ca" : {
@@ -282,7 +311,7 @@ func ResourceSystemCertificate() *schema.Resource {
282
311
Type : schema .TypeSet ,
283
312
Optional : true ,
284
313
ForceNew : true ,
285
- ConflictsWith : []string {"sign" },
314
+ ConflictsWith : []string {"acme_ssl_certificate" , " sign" },
286
315
Elem : & schema.Resource {
287
316
Schema : map [string ]* schema.Schema {
288
317
"scep_url" : {
@@ -426,11 +455,13 @@ func ResourceSystemCertificate() *schema.Resource {
426
455
var command string // MikroTik command to sign certificate
427
456
var ok bool
428
457
429
- if _ , ok = d .GetOk ("import" ); ! ok {
430
- // Run DefaultCreate.
431
- diags = ResourceCreate (ctx , resSchema , d , m )
432
- if diags .HasError () {
433
- return diags
458
+ if _ , ok = d .GetOk ("acme_ssl_certificate" ); ! ok {
459
+ if _ , ok = d .GetOk ("import" ); ! ok {
460
+ // Run DefaultCreate.
461
+ diags = ResourceCreate (ctx , resSchema , d , m )
462
+ if diags .HasError () {
463
+ return diags
464
+ }
434
465
}
435
466
}
436
467
@@ -447,6 +478,11 @@ func ResourceSystemCertificate() *schema.Resource {
447
478
crudMethod = crudSignViaScep
448
479
// https://router/rest/certificate/add-scep
449
480
command = "/add-scep"
481
+ } else if cmdBlock , ok = d .GetOk ("acme_ssl_certificate" ); ok {
482
+ params = MikrotikItem {"dns-name" : d .Get ("common_name" ).(string )}
483
+ crudMethod = crudEnableSslCertificate
484
+ // https://router/rest/certificate/enable-ssl-certificate
485
+ command = "/enable-ssl-certificate"
450
486
} else if cmdBlock , ok = d .GetOk ("import" ); ok {
451
487
return certImport (ctx , cmdBlock , d , m )
452
488
} else {
@@ -481,6 +517,17 @@ func ResourceSystemCertificate() *schema.Resource {
481
517
return diag .FromErr (err )
482
518
}
483
519
520
+ if command == "/enable-ssl-certificate" {
521
+ d .SetId (d .Get ("name" ).(string ))
522
+ id , err := dynamicIdLookup (Name , resSchema [MetaResourcePath ].Default .(string ), m .(Client ), d )
523
+
524
+ if err != nil {
525
+ return diag .FromErr (err )
526
+ }
527
+
528
+ d .SetId (id )
529
+ }
530
+
484
531
return ResourceRead (ctx , resSchema , d , m )
485
532
}
486
533
0 commit comments