(ctx *cli.Context, subject *string)
| 374 | } |
| 375 | |
| 376 | func (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 | |
| 408 | func (f *revokeFlow) Revoke(ctx *cli.Context, serial, token string) error { |
| 409 | client, err := f.getClient(ctx, serial, token) |
no test coverage detected