Skip to content

Commit 4204482

Browse files
authored
Merge pull request #179
fix: ConnectionFactory incorrectly using SmartCardConnection
2 parents 9867d2d + 1160d51 commit 4204482

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
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
}

Yubico.YubiKey/src/Yubico/YubiKey/Oath/OathSession.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,9 @@ protected override void Dispose(bool disposing)
127127
{
128128
if (disposing)
129129
{
130-
return;
130+
KeyCollector = null;
131+
base.Dispose(disposing);
131132
}
132-
133-
KeyCollector = null;
134-
base.Dispose(disposing);
135133
}
136134
}
137135
}

0 commit comments

Comments
 (0)