mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-11 11:19:39 +02:00
Fix NPE when sop generate-key --with-key-password is used with multiple uids
Fixes #351
This commit is contained in:
parent
980daeca31
commit
3b2d0795f7
2 changed files with 4 additions and 1 deletions
|
@ -51,6 +51,7 @@ public class GenerateKeyImpl implements GenerateKey {
|
|||
@Override
|
||||
public Ready generate() throws SOPGPException.MissingArg, SOPGPException.UnsupportedAsymmetricAlgo {
|
||||
Iterator<String> userIdIterator = userIds.iterator();
|
||||
Passphrase passphraseCopy = new Passphrase(passphrase.getChars()); // generateKeyRing clears the original passphrase
|
||||
PGPSecretKeyRing key;
|
||||
try {
|
||||
String primaryUserId = userIdIterator.hasNext() ? userIdIterator.next() : null;
|
||||
|
@ -61,7 +62,7 @@ public class GenerateKeyImpl implements GenerateKey {
|
|||
SecretKeyRingEditorInterface editor = PGPainless.modifyKeyRing(key);
|
||||
|
||||
while (userIdIterator.hasNext()) {
|
||||
editor.addUserId(userIdIterator.next(), SecretKeyRingProtector.unprotectedKeys());
|
||||
editor.addUserId(userIdIterator.next(), SecretKeyRingProtector.unlockAnyKeyWith(passphraseCopy));
|
||||
}
|
||||
|
||||
key = editor.done();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue