Skip to content

Commit abf8c71

Browse files
committed
fix: bug where SDK would print a failure log even though we were successful (PivSession)
- additional: added param docs for mutualAuthentication
1 parent a7b54cc commit abf8c71

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.ManagementKey.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ private bool TryAuthenticateWithKeyCollector(bool mutualAuthentication)
299299
/// further documentation on this method.
300300
/// </para>
301301
/// </remarks>
302+
/// <param name="mutualAuthentication">
303+
/// If <c>true</c> the method will perform mutual authentication, if
304+
/// <c>false</c>, only the application will authenticate to the YubiKey.
305+
/// </param>
302306
/// <exception cref="InvalidOperationException">
303307
/// There is no <c>KeyCollector</c> loaded, the key provided was not a
304308
/// valid Triple-DES or AES key, or the YubiKey had some other error, such as
@@ -320,7 +324,7 @@ public void AuthenticateManagementKey(bool mutualAuthentication = true)
320324
Logger.LogInformation(
321325
$"Authenticate the management key: {(mutualAuthentication ? "mutual" : "single")} auth.");
322326

323-
if (TryAuthenticateManagementKey(mutualAuthentication) == false)
327+
if (!TryAuthenticateManagementKey(mutualAuthentication))
324328
{
325329
throw new OperationCanceledException(
326330
string.Format(
@@ -1009,11 +1013,12 @@ private bool TryAuthenticateManagementKey(
10091013
}
10101014

10111015
ManagementKeyAuthenticated = true;
1016+
return true;
10121017
}
10131018

10141019
Logger.LogInformation($"Failed to authenticate management key. Message: {completeResponse.StatusMessage}");
10151020

1016-
return ManagementKeyAuthenticated;
1021+
return false;
10171022
}
10181023

10191024
private void RefreshManagementKeyAlgorithm() => ManagementKeyAlgorithm = GetManagementKeyAlgorithm();

0 commit comments

Comments
 (0)