Skip to content

Commit 0c7f916

Browse files
committed
fix: ConnectionFactory incorrectly using SmartCardConnection instead of FIDO2Connection
1 parent c100ab1 commit 0c7f916

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Yubico.YubiKey/src/Yubico/YubiKey/ConnectionFactory.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,6 @@ public IScpYubiKeyConnection CreateScpConnection(YubiKeyApplication application,
112112
/// </remarks>
113113
public IYubiKeyConnection CreateConnection(YubiKeyApplication application)
114114
{
115-
if (_smartCardDevice != null)
116-
{
117-
_log.LogDebug("Connecting via the SmartCard interface.");
118-
119-
WaitForReclaimTimeout(Transport.SmartCard);
120-
return new SmartCardConnection(_smartCardDevice, application);
121-
}
122-
123115
if (_hidKeyboardDevice != null && application == YubiKeyApplication.Otp)
124116
{
125117
_log.LogDebug("Connecting via the Keyboard interface.");
@@ -128,13 +120,22 @@ public IYubiKeyConnection CreateConnection(YubiKeyApplication application)
128120
return new KeyboardConnection(_hidKeyboardDevice);
129121
}
130122

131-
if (_hidFidoDevice != null && (application == YubiKeyApplication.Fido2 || application == YubiKeyApplication.FidoU2f))
123+
bool isFidoApplication = application == YubiKeyApplication.Fido2 || application == YubiKeyApplication.FidoU2f;
124+
if (_hidFidoDevice != null && isFidoApplication)
132125
{
133126
_log.LogDebug("Connecting via the FIDO interface.");
134127

135128
WaitForReclaimTimeout(Transport.HidFido);
136129
return new FidoConnection(_hidFidoDevice);
137130
}
131+
132+
if (_smartCardDevice != null)
133+
{
134+
_log.LogDebug("Connecting via the SmartCard interface.");
135+
136+
WaitForReclaimTimeout(Transport.SmartCard);
137+
return new SmartCardConnection(_smartCardDevice, application);
138+
}
138139

139140
throw new InvalidOperationException("No suitable interface present. Unable to establish connection to YubiKey.");
140141
}

0 commit comments

Comments
 (0)