Skip to content

fix(cli): handle empty password in signer generate and sign commands#14941

Open
veeceey wants to merge 2 commits intotauri-apps:devfrom
veeceey:fix/issue-14829-empty-password-signing
Open

fix(cli): handle empty password in signer generate and sign commands#14941
veeceey wants to merge 2 commits intotauri-apps:devfrom
veeceey:fix/issue-14829-empty-password-signing

Conversation

@veeceey
Copy link
Contributor

@veeceey veeceey commented Feb 14, 2026

Summary

Fixes an issue where running tauri signer generate -p "" followed by tauri signer sign -p "" would fail with incorrect updater private key password: Wrong password for that key.

The root cause is in how minisign handles empty passwords internally:

  • generate_encrypted_keypair(Some("")) sets KDF parameters (scrypt algorithm, salt, etc.) but skips actual encryption because password.is_empty() is true
  • into_secret_key(Some("")) sees the KDF parameters and attempts scrypt-based decryption on data that was never encrypted
  • The decryption corrupts the key data and the checksum fails

The fix normalizes empty passwords to None and uses the appropriate unencrypted key APIs:

  • generate_key: uses generate_unencrypted_keypair() when password is empty
  • secret_key: uses into_unencrypted_secret_key() when password is empty

This ensures keys generated without a password are properly stored as unencrypted (KDF_NONE) and can be loaded without attempting decryption.

Closes #14829

Test plan

  • Added generate_and_sign_with_empty_password test - roundtrip generate + sign with Some("")
  • Added generate_and_sign_with_no_password test - roundtrip generate + sign with None
  • Added generate_with_password_and_sign test - roundtrip with actual password
  • Added empty_password_sign_then_none_sign_are_interchangeable test - verifies Some("") and None are treated identically
  • All 4 tests pass locally

When generating or signing with an empty password (`-p ""`), minisign's
`generate_encrypted_keypair(Some(""))` sets KDF parameters but skips
actual encryption, creating an inconsistent key state. Later,
`into_secret_key(Some(""))` tries scrypt decryption on unencrypted data,
corrupting it and failing with "Wrong password for that key".

Fix by normalizing empty passwords to None and using the appropriate
unencrypted key APIs:
- generate_key: use generate_unencrypted_keypair() for empty passwords
- secret_key: use into_unencrypted_secret_key() for empty passwords

Closes tauri-apps#14829
@veeceey veeceey requested a review from a team as a code owner February 14, 2026 10:53
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

[bug] Can not use empty string as the password of signing private key

1 participant