-
Notifications
You must be signed in to change notification settings - Fork 0
/
certs.go
614 lines (514 loc) · 23.3 KB
/
certs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
package apicupcfg
import (
"fmt"
rice "github.com/GeertJohan/go.rice"
)
type CertSpec struct {
Cn string
CertName string
DnFields []string
K8sNamespace string
SubsysName string
KeyFile string
CertFile string
CaFile string
CsrConf string
CsrSubdir string // csr subdirectory relative to the base output directory
CertSubdir string // cert subdirectory relative to the base output directory
KeySubdir string // key subdirectory relative tp the base output directory
CaSubdir string // ca subdirectory relative to the base output directory
AltCns [] string // a list of alt cn's
}
type OsEnvCerts struct {
OsEnv OsEnv
CertSpecs map[string]CertSpec
}
type OsEnvCert struct {
OsEnv OsEnv
CertSpec CertSpec
Passive bool
}
type Certbot struct {
CertDir string
Cert string
Key string
CaChain string
}
type Certs struct {
DnFields []string
K8sNamespace string
//CaFile string
PublicUserFacingCerts bool
PublicCerts bool
CommonCerts bool
PublicUserFacingEkuServerAuth map[string]CertSpec
PublicEkuServerAuth map[string]CertSpec
MutualAuthEkuServerAuth map[string]CertSpec
CommonEkuClientAuth map[string]CertSpec
//Certbot Certbot
//SharedEndpointTrust bool
etCertSpecMgt CertSpec
etCertSpecPtl CertSpec
etCertSpecAlyt CertSpec
etCertSpecGwy CertSpec
OsEnv
Passive bool
}
// subsystem certs
const CertKeyPlatformApi = "platform-api"
const CertKeyConsumerApi = "consumer-api"
const CertKeyApiManagerUi = "api-manager-ui"
const CertKeyCloudAdminUi = "cloud-admin-ui"
const CertKeyPortalAdminIngress = "portal-admin-ingress"
const CertKeyPortalWwwIngress = "portal-www-ingress"
const CertKeyAnalyticsClientIngress = "analytics-client-ingress"
const CertKeyAnalyticsIngestionIngress = "analytics-ingestion-ingress"
const CertKeyApicGwServiceIngress = "apic-gw-service-ingress"
// common certs
const CertKeyPortalClient = "portal-client"
const CertKeyAnalyticsClientClient = "analytics-client-client"
const CertKeyAnalyticsIngestionClient = "analytics-ingestion-client"
// shared trust endpoint key files
const KeyFileSharedEndpointTrustManagement = "shared-endpoint-trust-management.key"
const KeyFileSharedEndpointTrustPortal = "shared-endpoint-trust-portal.key"
const KeyFileSharedEndpointTrustAnalytics = "shared-endpoint-trust-analytics.key"
const KeyFileSharedEndpointTrustGateway = "shared-endpoint-trust-gateway.key"
func updateCertSpec(certs *Certs, subsysName string, certName string, certSpec *CertSpec, csrSubdir string) {
// check if no cn...
if len(certSpec.Cn) == 0 {
return
}
if len(certSpec.CertName) == 0 {
certSpec.CertName = certName
}
if len(certSpec.DnFields) == 0 {
certSpec.DnFields = certs.DnFields
}
if len(certSpec.K8sNamespace) == 0 {
certSpec.K8sNamespace = certs.K8sNamespace
}
// ca chain file: issuing-ca + root-ca
if len(certSpec.CaFile) == 0 {
//certSpec.CaFile = certs.CaFile
certSpec.CaFile = dot2dash(certSpec.Cn) + ".chain.pem"
}
certSpec.SubsysName = subsysName
// default file names
if len(certSpec.CsrConf) == 0 {
certSpec.CsrConf = dot2dash(certSpec.Cn) + ".conf"
}
if len(certSpec.KeyFile) == 0 {
certSpec.KeyFile = dot2dash(certSpec.Cn) + ".key"
}
if len(certSpec.CertFile) == 0 {
certSpec.CertFile = dot2dash(certSpec.Cn) + ".crt"
}
if len(certSpec.CsrSubdir) == 0 {
certSpec.CsrSubdir = csrSubdir
}
if len(certSpec.CertSubdir) == 0 {
certSpec.CertSubdir = csrSubdir
}
if len(certSpec.KeySubdir) == 0 {
certSpec.KeySubdir = csrSubdir
}
if len(certSpec.CaSubdir) == 0 {
certSpec.CaSubdir = csrSubdir
}
// alt-cns
certSpec.AltCns = make([]string, 0, 500)
}
func createCertMaps(certs *Certs) {
if certs.PublicUserFacingEkuServerAuth == nil {
certs.PublicUserFacingEkuServerAuth = make(map[string]CertSpec)
}
if certs.PublicEkuServerAuth == nil {
certs.PublicEkuServerAuth = make(map[string]CertSpec)
}
if certs.MutualAuthEkuServerAuth == nil {
certs.MutualAuthEkuServerAuth = make(map[string]CertSpec)
}
if certs.CommonEkuClientAuth == nil {
certs.CommonEkuClientAuth = make(map[string]CertSpec)
}
}
func updateCertSpecs(certs *Certs, mgmt ManagementSubsysDescriptor, alyt AnalyticsSubsysDescriptor,
ptl PortalSubsysDescriptor, gwy GatewaySubsysDescriptor, commonCsrOutDir string, customCsrOutDir string) {
certs.OsEnv.init()
createCertMaps(certs)
isManagement := len(mgmt.GetManagementSubsysName()) > 0
isAnalytics := len(alyt.GetAnalyticsSubsysName()) > 0
isPortal := len(ptl.GetPortalSubsysName()) > 0
isGateway := len(gwy.GetGatewaySubsysName()) > 0
getCertSpec := func (certmap map[string]CertSpec, key string) CertSpec {
if certspec, ok := certmap[key]; ok {return certspec } else {return CertSpec{}}
}
if isManagement && certs.PublicUserFacingCerts {
// management subsystem contributes public-user-facing certs
// build cert specs
certmap := certs.PublicUserFacingEkuServerAuth
certSpec := getCertSpec(certmap, CertKeyPlatformApi)
certSpec.Cn = mgmt.GetPlatformApiEndpoint()
updateCertSpec(certs, mgmt.GetManagementSubsysName(), CertKeyPlatformApi, &certSpec, customCsrOutDir)
certmap[CertKeyPlatformApi] = certSpec
certSpec = getCertSpec(certmap, CertKeyConsumerApi)
certSpec.Cn = mgmt.GetConsumerApiEndpoint()
updateCertSpec(certs, mgmt.GetManagementSubsysName(), CertKeyConsumerApi, &certSpec, customCsrOutDir)
certmap[CertKeyConsumerApi] = certSpec
certSpec = getCertSpec(certmap, CertKeyApiManagerUi)
certSpec.Cn = mgmt.GetApiManagerUIEndpoint()
updateCertSpec(certs, mgmt.GetManagementSubsysName(), CertKeyApiManagerUi, &certSpec, customCsrOutDir)
certmap[CertKeyApiManagerUi] = certSpec
certSpec = getCertSpec(certmap,CertKeyCloudAdminUi)
certSpec.Cn = mgmt.GetCloudAdminUIEndpoint()
updateCertSpec(certs, mgmt.GetManagementSubsysName(), CertKeyCloudAdminUi, &certSpec, customCsrOutDir)
certmap[CertKeyCloudAdminUi] = certSpec
}
if isPortal && certs.PublicUserFacingCerts {
// portal subsystem contributes public-user-facing certs
certmap := certs.PublicUserFacingEkuServerAuth
certSpec := getCertSpec(certmap, CertKeyPortalWwwIngress)
certSpec.Cn = ptl.GetPortalWWWEndpoint()
updateCertSpec(certs, ptl.GetPortalSubsysName(), CertKeyPortalWwwIngress, &certSpec, customCsrOutDir)
certmap[CertKeyPortalWwwIngress] = certSpec
}
if isGateway && certs.PublicCerts {
// gateway contributes to public certs
certmap := certs.PublicEkuServerAuth
certSpec := getCertSpec(certmap, CertKeyApicGwServiceIngress)
certSpec.Cn = CertKeyApicGwServiceIngress
updateCertSpec(certs, gwy.GetGatewaySubsysName(), CertKeyApicGwServiceIngress, &certSpec, commonCsrOutDir)
certmap[CertKeyApicGwServiceIngress] = certSpec
}
if isManagement && certs.CommonCerts {
// common certs are set on the management subystem
certmap := certs.CommonEkuClientAuth
certSpec := getCertSpec(certmap, CertKeyPortalClient)
certSpec.Cn = CertKeyPortalClient
updateCertSpec(certs, mgmt.GetManagementSubsysName(), CertKeyPortalClient, &certSpec, commonCsrOutDir)
certmap[CertKeyPortalClient] = certSpec
certSpec = getCertSpec(certmap, CertKeyAnalyticsClientClient)
certSpec.Cn = CertKeyAnalyticsClientClient
updateCertSpec(certs, mgmt.GetManagementSubsysName(), CertKeyAnalyticsClientClient, &certSpec, commonCsrOutDir)
certmap[CertKeyAnalyticsClientClient] = certSpec
certSpec = getCertSpec(certmap, CertKeyAnalyticsIngestionClient)
certSpec.Cn = CertKeyAnalyticsIngestionClient
updateCertSpec(certs, mgmt.GetManagementSubsysName(), CertKeyAnalyticsIngestionClient, &certSpec, commonCsrOutDir)
certmap[CertKeyAnalyticsIngestionClient] = certSpec
}
if isPortal && certs.CommonCerts {
// portal subsystem contributes mutual auth server cert
certmap := certs.MutualAuthEkuServerAuth
certSpec := getCertSpec(certmap, CertKeyPortalAdminIngress)
certSpec.Cn = ptl.GetPortalAdminEndpoint()
updateCertSpec(certs, ptl.GetPortalSubsysName(), CertKeyPortalAdminIngress, &certSpec, commonCsrOutDir)
certmap[CertKeyPortalAdminIngress] = certSpec
}
if isAnalytics && certs.CommonCerts {
// analytics subsystem contributes mutual auth server certs
certmap := certs.MutualAuthEkuServerAuth
certSpec := getCertSpec(certmap, CertKeyAnalyticsIngestionIngress)
certSpec.Cn = alyt.GetAnalyticsIngestionEndpoint()
updateCertSpec(certs, alyt.GetAnalyticsSubsysName(), CertKeyAnalyticsIngestionIngress, &certSpec, commonCsrOutDir)
certSpec.AltCns = append(certSpec.AltCns, fmt.Sprintf("*.%s", certSpec.K8sNamespace))
certSpec.AltCns = append(certSpec.AltCns, fmt.Sprintf("*.%s.svc", certSpec.K8sNamespace))
certSpec.AltCns = append(certSpec.AltCns, fmt.Sprintf("*.%s.svc.cluster.local", certSpec.K8sNamespace))
certmap[CertKeyAnalyticsIngestionIngress] = certSpec
certSpec = getCertSpec(certmap, CertKeyAnalyticsClientIngress)
certSpec.Cn = alyt.GetAnalyticsClientEndpoint()
updateCertSpec(certs, alyt.GetAnalyticsSubsysName(), CertKeyAnalyticsClientIngress, &certSpec, commonCsrOutDir)
certSpec.AltCns = append(certSpec.AltCns, fmt.Sprintf("*.%s", certSpec.K8sNamespace))
certSpec.AltCns = append(certSpec.AltCns, fmt.Sprintf("*.%s.svc", certSpec.K8sNamespace))
certSpec.AltCns = append(certSpec.AltCns, fmt.Sprintf("*.%s.svc.cluster.local", certSpec.K8sNamespace))
certmap[CertKeyAnalyticsClientIngress] = certSpec
}
//// shared endpoint trust
//if certs.SharedEndpointTrust {
// setupSharedEndpointTrust(certs, mgmt, alyt, ptl, gwy, commonCsrOutDir, customCsrOutDir)
//}
}
func setupSharedEndpointTrust(certs *Certs, mgmt ManagementSubsysDescriptor, alyt AnalyticsSubsysDescriptor,
ptl PortalSubsysDescriptor, gwy GatewaySubsysDescriptor, commonCsrOutDir string, customCsrOutDir string) {
// mgmt
cs := &certs.etCertSpecMgt
cs.Cn = mgmt.GetPlatformApiEndpoint()
cs.CsrConf = "shared-endpoint-trust-management.conf"
cs.CsrSubdir = SharedCsrOutDir
cs.KeySubdir = SharedCsrOutDir
cs.KeyFile = KeyFileSharedEndpointTrustManagement
updateCertSpec(certs, mgmt.GetManagementSubsysName(), mgmt.GetManagementSubsysName(), cs, customCsrOutDir)
//cs.AltCns = append(cs.AltCns, mgmt.GetPlatformApiEndpoint())
cs.AltCns = append(cs.AltCns, mgmt.GetConsumerApiEndpoint())
cs.AltCns = append(cs.AltCns, mgmt.GetCloudAdminUIEndpoint())
cs.AltCns = append(cs.AltCns, mgmt.GetApiManagerUIEndpoint())
// ptl
cs = &certs.etCertSpecPtl
cs.Cn = ptl.GetPortalWWWEndpoint()
cs.CsrConf = "shared-endpoint-trust-portal.conf"
cs.CsrSubdir = SharedCsrOutDir
cs.KeySubdir = SharedCsrOutDir
cs.KeyFile = KeyFileSharedEndpointTrustPortal
updateCertSpec(certs, ptl.GetPortalSubsysName(), ptl.GetPortalSubsysName(), cs, customCsrOutDir)
//cs.AltCns = append(cs.AltCns, ptl.GetPortalWWWEndpoint())
cs.AltCns = append(cs.AltCns, ptl.GetPortalAdminEndpoint())
// alyt
cs = &certs.etCertSpecAlyt
cs.Cn = alyt.GetAnalyticsClientEndpoint()
cs.CsrConf = "shared-endpoint-trust-analytics.conf"
cs.CsrSubdir = SharedCsrOutDir
cs.KeySubdir = SharedCsrOutDir
cs.KeyFile = KeyFileSharedEndpointTrustAnalytics
updateCertSpec(certs, alyt.GetAnalyticsSubsysName(), alyt.GetAnalyticsSubsysName(), cs, customCsrOutDir)
//cs.AltCns = append(cs.AltCns, alyt.GetAnalyticsClientEndpoint())
cs.AltCns = append(cs.AltCns, alyt.GetAnalyticsIngestionEndpoint())
// gwy
cs = &certs.etCertSpecGwy
cs.Cn = gwy.GetApicGatewayServiceEndpoint()
cs.CsrConf = "shared-endpoint-trust-gateway.conf"
cs.CsrSubdir = SharedCsrOutDir
cs.KeySubdir = SharedCsrOutDir
cs.KeyFile = KeyFileSharedEndpointTrustGateway
updateCertSpec(certs, gwy.GetGatewaySubsysName(), gwy.GetGatewaySubsysName(), cs, customCsrOutDir)
//cs.AltCns = append(cs.AltCns, gwy.GetApicGatewayServiceEndpoint())
cs.AltCns = append(cs.AltCns, gwy.GetApiGatewayEndpoint())
}
func outputCerts(certs *Certs, outfiles map[string]string, tag string, version string, useVersion bool, tbox *rice.Box) {
ekuServerAuth := parseTemplate(tbox, tpdir(tbox) + "csr-server-auth.tmpl")
ekuClientAuth := parseTemplate(tbox, tpdir(tbox) + "csr-client-auth.tmpl")
keypairTemplate := parseTemplates(tbox, tpdir(tbox) + "keypair.tmpl", tpdir(tbox) + "helpers.tmpl")
combinedCsrTemplate := parseTemplates(tbox, tpdir(tbox) + "combined-csr.tmpl", tpdir(tbox) + "helpers.tmpl")
subsysCertsTemplate := parseTemplates(tbox, tpdir(tbox) + "subsys-certs.tmpl", tpdir(tbox) + "helpers.tmpl")
var outpath string
var osenv OsEnv
osenv.init2(version, useVersion)
// public-user-facing-eku-server-auth csr conf
if certs.PublicUserFacingCerts {
for _, certSpec := range certs.PublicUserFacingEkuServerAuth {
if len(certSpec.Cn) > 0 {
// csr
outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CustomCsrOutDir]), certSpec.CsrConf)
writeTemplate(ekuServerAuth, outpath, certSpec)
// key-pair
outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CustomCsrOutDir]), certSpec.CsrConf + osenv.ShellExt)
writeTemplate(keypairTemplate, outpath, OsEnvCert{OsEnv: osenv, CertSpec: certSpec, Passive: certs.Passive})
}
}
}
if certs.PublicCerts {
for _, certSpec := range certs.PublicEkuServerAuth {
if len(certSpec.Cn) > 0 {
// csr
outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CustomCsrOutDir]), certSpec.CsrConf)
writeTemplate(ekuServerAuth, outpath, certSpec)
// key-pair
outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CustomCsrOutDir]), certSpec.CsrConf + osenv.ShellExt)
writeTemplate(keypairTemplate, outpath, OsEnvCert{OsEnv: osenv, CertSpec: certSpec, Passive: certs.Passive})
}
}
}
if certs.CommonCerts {
for _, certSpec := range certs.MutualAuthEkuServerAuth {
if len(certSpec.Cn) > 0 {
// csr
outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CommonCsrOutDir]), certSpec.CsrConf)
writeTemplate(ekuServerAuth, outpath, certSpec)
// key-pair
outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CommonCsrOutDir]), certSpec.CsrConf + osenv.ShellExt)
writeTemplate(keypairTemplate, outpath, OsEnvCert{OsEnv: osenv, CertSpec: certSpec, Passive: certs.Passive})
}
}
for _, certSpec := range certs.CommonEkuClientAuth {
if len(certSpec.Cn) > 0 {
// csr
outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CommonCsrOutDir]), certSpec.CsrConf)
writeTemplate(ekuClientAuth, outpath, certSpec)
// key-pair
outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CommonCsrOutDir]), certSpec.CsrConf + osenv.ShellExt)
writeTemplate(keypairTemplate, outpath, OsEnvCert{OsEnv: osenv, CertSpec: certSpec, Passive: certs.Passive})
}
}
}
if certs.PublicUserFacingCerts {
// combine public-user-facing key and csr scripts
outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CustomCsrOutDir]), tagOutputFileName("all-user-facing-public-csr", tag) + osenv.ShellExt)
writeTemplate(combinedCsrTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: certs.PublicUserFacingEkuServerAuth})
}
if certs.PublicCerts {
// combine public key and csr scripts
outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CustomCsrOutDir]), tagOutputFileName("all-public-csr", tag) + osenv.ShellExt)
writeTemplate(combinedCsrTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: certs.PublicEkuServerAuth})
}
if certs.CommonCerts {
// combine mutual-auth key and csr scripts
outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CommonCsrOutDir]), tagOutputFileName("all-mutual-auth-csr", tag) + osenv.ShellExt)
writeTemplate(combinedCsrTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: certs.MutualAuthEkuServerAuth})
// combine common key and csr scripts
outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CommonCsrOutDir]), tagOutputFileName("all-common-csr", tag) + osenv.ShellExt)
writeTemplate(combinedCsrTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: certs.CommonEkuClientAuth})
}
if certs.PublicUserFacingCerts {
// apicup certs user-facing-public
outpath = fileName(outfiles["outdir"], tagOutputFileName(outfiles[userFacingPublicCertsOut], tag)) + osenv.ShellExt
writeTemplate(subsysCertsTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: certs.PublicUserFacingEkuServerAuth})
}
if certs.PublicCerts {
// apicup certs public
outpath = fileName(outfiles["outdir"], tagOutputFileName(outfiles[publicCertsOut], tag)) + osenv.ShellExt
writeTemplate(subsysCertsTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: certs.PublicEkuServerAuth})
}
if certs.CommonCerts {
// apicup certs mutual auth
outpath = fileName(outfiles["outdir"], tagOutputFileName(outfiles[mutualAuthCertsOut], tag)) + osenv.ShellExt
writeTemplate(subsysCertsTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: certs.MutualAuthEkuServerAuth})
// apicup certs common
outpath = fileName(outfiles["outdir"], tagOutputFileName(outfiles[commonCertsOut], tag)) + osenv.ShellExt
writeTemplate(subsysCertsTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: certs.CommonEkuClientAuth})
}
//if len(certs.Certbot.CertDir) > 0 {
//
// updateFromCertbot := func(certs map[string]CertSpec, certbot Certbot) map[string]CertSpec {
// cbmap := make(map[string]CertSpec)
// for cname, cs := range certs {
// cs.CsrSubdir = certbot.CertDir
// cs.CertSubdir = certbot.CertDir
// cs.KeySubdir = certbot.CertDir
// cs.CaSubdir = certbot.CertDir
// cs.KeyFile = certbot.Key
// cs.CertFile = certbot.Cert
// cs.CaFile = certbot.CaChain
// cbmap[cname] = cs
// }
// return cbmap
// }
//
// // apicup certs user-facing-public certbot
// if certs.PublicUserFacingCerts {
// cbmap := updateFromCertbot(certs.PublicUserFacingEkuServerAuth, certs.Certbot)
// outpath = fileName(outfiles["outdir"], tagOutputFileName(outfiles[certbotUserFacingPublicCertOut], tag)) + osenv.ShellExt
// writeTemplate(subsysCertsTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: cbmap})
// }
//
// // apicup certs public certbot
// if certs.PublicCerts {
// cbmap := updateFromCertbot(certs.PublicEkuServerAuth, certs.Certbot)
// outpath = fileName(outfiles["outdir"], tagOutputFileName(outfiles[certbotPublicCertOut], tag)) + osenv.ShellExt
// writeTemplate(subsysCertsTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: cbmap})
// }
//}
//if certs.SharedEndpointTrust {
//
// updateFromEndpointTrust := func(certs map[string]CertSpec, et map[string]CertSpec) map[string]CertSpec {
// cbmap := make(map[string]CertSpec)
// for cname, cs := range certs {
// // shared endpoint trust - one key shared by subsystem endpoints
// cs.KeySubdir = et[cname].KeySubdir
// cs.KeyFile = et[cname].KeyFile
// cbmap[cname] = cs
// }
// return cbmap
// }
//
// if certs.PublicUserFacingCerts {
// // mgmt
// certSpec := certs.etCertSpecMgt
//
// // csr
// outpath = fileName(concatSubdir(outfiles[outdir], outfiles[SharedCsrOutDir]), certSpec.CsrConf)
// writeTemplate(ekuServerAuth, outpath, certSpec)
//
// // key-pair
// outpath = fileName(concatSubdir(outfiles[outdir], outfiles[SharedCsrOutDir]), certSpec.CsrConf + osenv.ShellExt)
// writeTemplate(keypairTemplate, outpath, OsEnvCert{OsEnv: osenv, CertSpec: certSpec, Passive: certs.Passive})
//
// // ptl
// certSpec = certs.etCertSpecPtl
//
// // csr
// outpath = fileName(concatSubdir(outfiles[outdir], outfiles[SharedCsrOutDir]), certSpec.CsrConf)
// writeTemplate(ekuServerAuth, outpath, certSpec)
//
// // key-pair
// outpath = fileName(concatSubdir(outfiles[outdir], outfiles[SharedCsrOutDir]), certSpec.CsrConf + osenv.ShellExt)
// writeTemplate(keypairTemplate, outpath, OsEnvCert{OsEnv: osenv, CertSpec: certSpec, Passive: certs.Passive})
//
// // combine public-user-facing key and csr scripts
// certmap := make(map[string]CertSpec)
// certmap["shared-endpoint-trust-management"] = certs.etCertSpecMgt
// certmap["shared-endpoint-trust-portal"] = certs.etCertSpecPtl
//
// outpath = fileName(concatSubdir(outfiles[outdir], outfiles[SharedCsrOutDir]), tagOutputFileName("all-user-facing-public-csr", tag) + osenv.ShellExt)
// writeTemplate(combinedCsrTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: certmap})
//
// // apicup certs user-facing-public
// m := make(map[string]CertSpec)
// m[CertKeyPlatformApi] = certs.etCertSpecMgt
// m[CertKeyConsumerApi] = certs.etCertSpecMgt
// m[CertKeyApiManagerUi] = certs.etCertSpecMgt
// m[CertKeyCloudAdminUi] = certs.etCertSpecMgt
// m[CertKeyPortalWwwIngress] = certs.etCertSpecPtl
//
// outpath = fileName(outfiles["outdir"], tagOutputFileName(outfiles[etUserFacingPublicCertsOut], tag)) + osenv.ShellExt
// writeTemplate(subsysCertsTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: updateFromEndpointTrust(certs.PublicUserFacingEkuServerAuth, m)})
// }
//
// if certs.PublicCerts {
// // gateway
// certSpec := certs.etCertSpecGwy
//
// // csr
// outpath = fileName(concatSubdir(outfiles[outdir], outfiles[SharedCsrOutDir]), certSpec.CsrConf)
// writeTemplate(ekuServerAuth, outpath, certSpec)
//
// // key-pair
// outpath = fileName(concatSubdir(outfiles[outdir], outfiles[SharedCsrOutDir]), certSpec.CsrConf + osenv.ShellExt)
// writeTemplate(keypairTemplate, outpath, OsEnvCert{OsEnv: osenv, CertSpec: certSpec, Passive: certs.Passive})
//
// // combine public key and csr scripts
// certmap := make(map[string]CertSpec)
// certmap["shared-endpoint-trust-gateway"] = certs.etCertSpecGwy
//
// outpath = fileName(concatSubdir(outfiles[outdir], outfiles[SharedCsrOutDir]), tagOutputFileName("all-public-csr", tag) + osenv.ShellExt)
// writeTemplate(combinedCsrTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: certmap})
//
// // apicup certs public
// m := make(map[string]CertSpec)
// m[CertKeyApicGwServiceIngress] = certs.etCertSpecGwy
//
// outpath = fileName(outfiles["outdir"], tagOutputFileName(outfiles[etPublicCertsOut], tag)) + osenv.ShellExt
// writeTemplate(subsysCertsTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: updateFromEndpointTrust(certs.PublicEkuServerAuth, m)})
// }
//
// if certs.CommonCerts {
// // alyt
// certSpec := certs.etCertSpecAlyt
//
// // csr
// outpath = fileName(concatSubdir(outfiles[outdir], outfiles[SharedCsrOutDir]), certSpec.CsrConf)
// writeTemplate(ekuServerAuth, outpath, certSpec)
//
// // key-pair
// outpath = fileName(concatSubdir(outfiles[outdir], outfiles[SharedCsrOutDir]), certSpec.CsrConf + osenv.ShellExt)
// writeTemplate(keypairTemplate, outpath, OsEnvCert{OsEnv: osenv, CertSpec: certSpec, Passive: certs.Passive})
//
// // combine mutual-auth key and csr scripts
// certmap := make(map[string]CertSpec)
// certmap["shared-endpoint-trust-analytics"] = certs.etCertSpecAlyt
//
// outpath = fileName(concatSubdir(outfiles[outdir], outfiles[SharedCsrOutDir]), tagOutputFileName("all-mutual-auth-csr", tag) + osenv.ShellExt)
// writeTemplate(combinedCsrTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: certmap})
//
// // combine common key and csr scripts
// //outpath = fileName(concatSubdir(outfiles[outdir], outfiles[CommonCsrOutDir]), tagOutputFileName("all-common-csr", tag) + osenv.ShellExt)
// //writeTemplate(combinedCsrTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: certs.CommonEkuClientAuth})
//
// // apicup certs mutual auth
// m := make(map[string]CertSpec)
// m[CertKeyAnalyticsClientIngress] = certs.etCertSpecAlyt
// m[CertKeyAnalyticsIngestionIngress] = certs.etCertSpecAlyt
// m[CertKeyPortalAdminIngress] = certs.etCertSpecPtl
//
// outpath = fileName(outfiles["outdir"], tagOutputFileName(outfiles[etMutualAuthCertsOut], tag)) + osenv.ShellExt
// writeTemplate(subsysCertsTemplate, outpath, OsEnvCerts{OsEnv: osenv, CertSpecs: updateFromEndpointTrust(certs.MutualAuthEkuServerAuth,m)})
// }
//}
}