我们正在使用 Visual Studio 2019 开发 C# UWP 应用程序。我已成功设置监控正在从 USB 端口插入/移除的 YubiKey FIPS(4.4.5 固件)。我们将 YubiKey 设置为使用 PIV,并将证书加载到插槽 9c(使用 YubiKey PIV 管理器,我没有安装迷你驱动程序)。我确实注意到,当 YubiKey 插入 USB 时,它会使用插槽 9c 中的证书自动加载我的个人证书存储。我们收到来自服务器的质询,我需要使用它来验证 YubiKey。从插槽 9c 获取证书的下一步是什么(如果该密钥上有多个证书怎么办)?Yubico 没有显示如何将密钥与应用程序集成的示例(我不相信 Windows Hello 在这里适用,不是吗?)。我们正在尝试使用 Windows.Devices。智能卡命名空间。这个命名空间似乎没有槽的概念。这是正确的方向还是我们需要使用 Yubico 库(迷你驱动程序)我不知道。文档是有限的。
var yubiKeys = Readers.Where(r => r.Value.Name.Contains("Yubi", StringComparison.OrdinalIgnoreCase));
foreach (KeyValuePair<string, SmartCardReader> item in yubiKeys)
{
IReadOnlyList<SmartCard> cards = await item.Value.FindAllCardsAsync();
foreach(SmartCard card in cards)
{
SmartCardProvisioning prov = await SmartCardProvisioning.FromSmartCardAsync(card);
using (SmartCardChallengeContext context = await prov.GetChallengeContextAsync())
{
IBuffer yubiKeyChallenge = context.Challenge; // IS THIS THE CARDS ADMIN PIN?
// Challenge to acquire cert here perhaps?
// the card object has no concept of slots, would each slot be a card in the reader?
// if so, how would I use the Challenge for that card?
}
}
}