go-piv / piv-go

Keys and certificates for YubiKeys, written in Go
Apache License 2.0
345 stars 61 forks source link

Error: Unable to open the Yubikey card: connecting to smart card: the smart card cannot be accessed because of other connections outstanding #116

Open dud225 opened 1 year ago

dud225 commented 1 year ago

Hello

I'm able to build a program with this library that allows me to successfully interact with my YubiKey. However under some conditions, e.g. after some idle period, I'm getting the aforementioned erorr:

Error: Unable to open the Yubikey card: connecting to smart card: the smart card cannot be accessed because of other connections outstanding

I'm not sure if there is anything wrong with piv-go. But I'm quite puzzled since I make thorough use of the Close() method and additionally I don't get this error with other tools e.g. libykcs11.so.

udf2457 commented 1 year ago

I stumbled accross this one today too.

I am using Close() but this does not appear to be honoured.

Even if I add time.Sleep(20 * time.Second) after Close() , piv-go still seems to be holding on to that connection.