refactor getVerifier()

This commit is contained in:
David Blacka 2024-03-29 21:58:16 -04:00
parent 31f35a17f8
commit 15eb319b26

View File

@ -264,18 +264,21 @@ public class DnsKeyPair {
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
public Signature getVerifier() { public Signature getVerifier() {
if (mVerifier == null) { if (mVerifier != null) return mVerifier;
mVerifier = getSignature();
PublicKey pk = getPublic(); mVerifier = getSignature();
if (mVerifier != null && pk != null) { PublicKey pk = getPublic();
try {
mVerifier.initVerify(pk); if (mVerifier == null || pk == null) {
} catch (InvalidKeyException e) { log.warning("Could not get a Signature object for this key pair" + this);
} return null;
} else { }
// do not return an uninitialized verifier
return null; try {
} mVerifier.initVerify(pk);
} catch (InvalidKeyException e) {
log.warning("Key pair cannot initialize with public key: " + this);
return null;
} }
return mVerifier; return mVerifier;