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

[Question]: Establish PIV session with device #81

Open
1 task done
briggst1 opened this issue May 3, 2024 · 5 comments
Open
1 task done

[Question]: Establish PIV session with device #81

briggst1 opened this issue May 3, 2024 · 5 comments
Labels
awaiting yubico action When we've got the ball question Further information is requested

Comments

@briggst1
Copy link

briggst1 commented May 3, 2024

Is there an existing issue for this?

  • I have searched the existing issues

What is your question?

I am having difficulty with establishing a PIV session with a key that is already plugged in.

Currently, I have code something like the following. Most of the time this works fine. However, sometimes, I get the System.NotSupportedException with the what() indicating that a PIV session could not be created.

Note: I tried using the yubikey listener from the sample code and had similar results: sometimes it would not get PIV session, other times its just fine.

Thoughts? Something I'm doing / not doing?

foreach (var dev in YubiKeyDevice.FindAll())
{
   try {
       System.Threading.Thread.Sleep(125);
       session = new PivSession(dev);
   }
    catch (Yubico.PlatformInterop.SCardException e)
 {
     MessageBox.Show("Error " + e.Message);
     Debug.Write("Error " + e.Message);
     Debug.Write(e.StackTrace);
     return false;
 }
 catch (System.NotSupportedException e)
 {
     MessageBox.Show(e.Message);
     Debug.Write("Error " + e.Message);
     return false;
 }

Context

No response

@briggst1 briggst1 added the question Further information is requested label May 3, 2024
@DennisDyallo
Copy link
Collaborator

Hi @briggst1 and thanks for checking out the SDK.

I'm new to the codebase myself but upon first glance it makes me want to direct you to this SDK article on creating and disposting connections:

https://docs.yubico.com/yesdk/users-manual/sdk-programming-guide/making-a-connection.html#2a-session

Specifically around the opening (and disposing) of a Session. If you follow the steps from this, do you still encounter the same behaviour?

@GregDomzalski
Copy link
Contributor

I suspect this could be a manifestation of #72

@DennisDyallo
Copy link
Collaborator

Are you still experiencing problems @briggst1 ?

@briggst1
Copy link
Author

briggst1 commented May 20, 2024

Yes, there are still times where, when the YubiKey is already plugged in, then I start my application, I get the same error. However, instructing the user to remove the key and re-insert, generally works around the problem. With the workaround, it is more of a nuisance / training issue than a blocking issue.

@DennisDyallo
Copy link
Collaborator

I see. Well, I'm still getting used to the codebase myself, but I think there's more related work that might address the issue. e.g. #89. Once it's merged you can try the latest develop branch and build it yourself/download and reference directly and see if you still experience the issue.

@DennisDyallo DennisDyallo added awaiting yubico action When we've got the ball and removed awaiting reply labels May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting yubico action When we've got the ball question Further information is requested
Development

No branches or pull requests

3 participants