MCPcopy Index your code
hub / github.com/smallstep/cli / GenerateToken

Method GenerateToken

command/ca/revoke.go:376–406  ·  view source on GitHub ↗
(ctx *cli.Context, subject *string)

Source from the content-addressed store, hash-verified

374}
375
376func (f *revokeFlow) GenerateToken(ctx *cli.Context, subject *string) (string, error) {
377 // For offline just generate the token
378 if f.offline {
379 return f.offlineCA.GenerateToken(ctx, cautils.RevokeType, *subject, nil, time.Time{}, time.Time{}, provisioner.TimeDuration{}, provisioner.TimeDuration{})
380 }
381
382 // Use online CA to get the provisioners and generate the token
383 caURL, err := flags.ParseCaURLIfExists(ctx)
384 if err != nil {
385 return "", err
386 } else if caURL == "" {
387 return "", errs.RequiredUnlessFlag(ctx, "ca-url", "token")
388 }
389
390 root := ctx.String("root")
391 if root == "" {
392 root = pki.GetRootCAPath()
393 if _, err := os.Stat(root); err != nil {
394 return "", errs.RequiredUnlessFlag(ctx, "root", "token")
395 }
396 }
397
398 if *subject == "" {
399 *subject, err = ui.Prompt("What is the Serial Number of the certificate you would like to revoke? (`step certificate inspect foo.cert`)", ui.WithValidateNotEmpty())
400 if err != nil {
401 return "", err
402 }
403 }
404
405 return cautils.NewTokenFlow(ctx, cautils.RevokeType, *subject, nil, caURL, root, time.Time{}, time.Time{}, provisioner.TimeDuration{}, provisioner.TimeDuration{})
406}
407
408func (f *revokeFlow) Revoke(ctx *cli.Context, serial, token string) error {
409 client, err := f.getClient(ctx, serial, token)

Callers 1

revokeCertificateActionFunction · 0.45

Calls 3

ParseCaURLIfExistsFunction · 0.92
NewTokenFlowFunction · 0.92
StringMethod · 0.65

Tested by

no test coverage detected