diff --git a/cmd/cosign/cli/pkcs11cli/commands.go b/cmd/cosign/cli/pkcs11cli/commands.go index fd356515c03..6d4609f5161 100644 --- a/cmd/cosign/cli/pkcs11cli/commands.go +++ b/cmd/cosign/cli/pkcs11cli/commands.go @@ -205,6 +205,9 @@ func GetKeysInfo(_ context.Context, modulePath string, slotID uint, pin string) } func ListTokensCmd(ctx context.Context, modulePath string) error { + if modulePath == "" { + return fmt.Errorf("please specify --module-path or set COSIGN_PKCS11_MODULE_PATH") + } tokens, err := GetTokens(ctx, modulePath) if err != nil { return err @@ -223,6 +226,9 @@ func ListTokensCmd(ctx context.Context, modulePath string) error { } func ListKeysUrisCmd(ctx context.Context, modulePath string, slotID uint, pin string) error { + if modulePath == "" { + return fmt.Errorf("please specify --module-path or set COSIGN_PKCS11_MODULE_PATH") + } keysInfo, err := GetKeysInfo(ctx, modulePath, slotID, pin) if err != nil { return err