GUACAMOLE-641: Use "KeyPair" typed field for private key only if non-empty.

An SSH server record in KSM has an associated "KeyPair" field, but this
field need not be set. If unset, the current logic ignores the rest of
the record and assumes there is no private key at all. Instead, the
standard fallbacks of locating an attached PEM file, locating an
alternative password field, etc. should be used.
This commit is contained in:
Michael Jumper
2022-01-30 11:33:14 -08:00
parent a0d8a7a4ef
commit ed14fa3ecf

View File

@@ -434,8 +434,11 @@ public class KsmRecordService {
// Attempt to find single matching keypair field // Attempt to find single matching keypair field
KeyPairs keyPairsField = getField(record, KeyPairs.class, PRIVATE_KEY_LABEL_PATTERN); KeyPairs keyPairsField = getField(record, KeyPairs.class, PRIVATE_KEY_LABEL_PATTERN);
if (keyPairsField != null) if (keyPairsField != null) {
return CompletableFuture.completedFuture(getSingleValue(keyPairsField.getValue(), KeyPair::getPrivateKey)); String privateKey = getSingleValue(keyPairsField.getValue(), KeyPair::getPrivateKey);
if (privateKey != null && !privateKey.isEmpty())
return CompletableFuture.completedFuture(privateKey);
}
// Lacking a typed keypair field, prefer a PEM-type attachment // Lacking a typed keypair field, prefer a PEM-type attachment
KeeperFile keyFile = getFile(record, PRIVATE_KEY_FILENAME_PATTERN); KeeperFile keyFile = getFile(record, PRIVATE_KEY_FILENAME_PATTERN);