MCPcopy
hub / github.com/smallstep/cli / createAction

Function createAction

command/certificate/create.go:495–771  ·  view source on GitHub ↗
(ctx *cli.Context)

Source from the content-addressed store, hash-verified

493}
494
495func createAction(ctx *cli.Context) error {
496 minArg := 2
497 if key := ctx.String("key"); key == "" {
498 minArg = 3
499 }
500 if err := errs.MinMaxNumberOfArguments(ctx, minArg, 3); err != nil {
501 return err
502 }
503
504 insecureMode := ctx.Bool("insecure")
505 noPass := ctx.Bool("no-password")
506 if noPass && !insecureMode {
507 return errs.RequiredWithFlag(ctx, "no-password", "insecure")
508 }
509
510 subject := ctx.Args().Get(0)
511 crtFile := ctx.Args().Get(1)
512 keyFile := ctx.Args().Get(2)
513 if crtFile == keyFile {
514 return errs.EqualArguments(ctx, "<crt-file>", "<key-file>")
515 }
516
517 notBefore, ok := flags.ParseTimeOrDuration(ctx.String("not-before"))
518 if !ok {
519 return errs.InvalidFlagValue(ctx, "not-before", ctx.String("not-before"), "")
520 }
521 notAfter, ok := flags.ParseTimeOrDuration(ctx.String("not-after"))
522 if !ok {
523 return errs.InvalidFlagValue(ctx, "not-after", ctx.String("not-after"), "")
524 }
525 if !notAfter.IsZero() && !notBefore.IsZero() && notBefore.After(notAfter) {
526 return errs.IncompatibleFlagValues(ctx, "not-before", ctx.String("not-before"), "not-after", ctx.String("not-after"))
527 }
528
529 var (
530 sans = ctx.StringSlice("san")
531 profile = ctx.String("profile")
532 templateFile = ctx.String("template")
533 bundle = ctx.Bool("bundle")
534 subtle = ctx.Bool("subtle")
535 skipCSRSignature = ctx.Bool("skip-csr-signature")
536 )
537
538 if ctx.IsSet("profile") && templateFile != "" {
539 return errs.IncompatibleFlagWithFlag(ctx, "profile", "template")
540 }
541
542 if ctx.Bool("csr") && skipCSRSignature {
543 return errs.IncompatibleFlagWithFlag(ctx, "csr", "skip-csr-signature")
544 }
545
546 // Read template if passed
547 var template string
548 if templateFile != "" {
549 b, err := utils.ReadFile(templateFile)
550 if err != nil {
551 return err
552 }

Callers

nothing calls this directly

Calls 9

ParseTimeOrDurationFunction · 0.92
ReadFileFunction · 0.92
GetTemplateDataFunction · 0.92
IsKMSSignerFunction · 0.92
parseOrCreateKeyFunction · 0.85
savePrivateKeyFunction · 0.85
parseSignerFunction · 0.85
GetCertificateMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…