Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ConnectionFactory incorrectly using SmartCardConnection #179

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions Yubico.YubiKey/src/Yubico/YubiKey/ConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ public IScpYubiKeyConnection CreateScpConnection(YubiKeyApplication application,
/// </remarks>
public IYubiKeyConnection CreateConnection(YubiKeyApplication application)
{
if (_smartCardDevice != null)
{
_log.LogDebug("Connecting via the SmartCard interface.");

WaitForReclaimTimeout(Transport.SmartCard);
return new SmartCardConnection(_smartCardDevice, application);
}

if (_hidKeyboardDevice != null && application == YubiKeyApplication.Otp)
{
_log.LogDebug("Connecting via the Keyboard interface.");
Expand All @@ -128,13 +120,22 @@ public IYubiKeyConnection CreateConnection(YubiKeyApplication application)
return new KeyboardConnection(_hidKeyboardDevice);
}

if (_hidFidoDevice != null && (application == YubiKeyApplication.Fido2 || application == YubiKeyApplication.FidoU2f))
bool isFidoApplication = application == YubiKeyApplication.Fido2 || application == YubiKeyApplication.FidoU2f;
if (_hidFidoDevice != null && isFidoApplication)
{
_log.LogDebug("Connecting via the FIDO interface.");

WaitForReclaimTimeout(Transport.HidFido);
return new FidoConnection(_hidFidoDevice);
}

if (_smartCardDevice != null)
{
_log.LogDebug("Connecting via the SmartCard interface.");

WaitForReclaimTimeout(Transport.SmartCard);
return new SmartCardConnection(_smartCardDevice, application);
}

throw new InvalidOperationException("No suitable interface present. Unable to establish connection to YubiKey.");
}
Expand Down
6 changes: 2 additions & 4 deletions Yubico.YubiKey/src/Yubico/YubiKey/Oath/OathSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@ protected override void Dispose(bool disposing)
{
if (disposing)
{
return;
KeyCollector = null;
base.Dispose(disposing);
}

KeyCollector = null;
base.Dispose(disposing);
}
}
}
Loading