diff --git a/piv/pcsc_unix.go b/piv/pcsc_unix.go index 55d6318..d6c9afa 100644 --- a/piv/pcsc_unix.go +++ b/piv/pcsc_unix.go @@ -93,7 +93,7 @@ func (c *scContext) Connect(reader string) (*scHandle, error) { activeProtocol C.DWORD ) rc := C.SCardConnect(c.ctx, C.CString(reader), - C.SCARD_SHARE_EXCLUSIVE, C.SCARD_PROTOCOL_T1, + C.SCARD_SHARE_SHARED, C.SCARD_PROTOCOL_T1, &handle, &activeProtocol) if err := scCheck(rc); err != nil { return nil, err diff --git a/piv/piv_test.go b/piv/piv_test.go index 534b259..270a252 100644 --- a/piv/piv_test.go +++ b/piv/piv_test.go @@ -105,44 +105,6 @@ func TestNewYubiKey(t *testing.T) { defer close() } -func TestMultipleConnections(t *testing.T) { - cards, err := Cards() - if err != nil { - t.Fatalf("listing cards: %v", err) - } - for _, card := range cards { - if !strings.Contains(strings.ToLower(card), "yubikey") { - continue - } - if !canModifyYubiKey { - t.Skip("not running test that accesses yubikey, provide --wipe-yubikey flag") - } - yk, err := Open(card) - if err != nil { - t.Fatalf("getting new yubikey: %v", err) - } - defer func() { - if err := yk.Close(); err != nil { - t.Errorf("closing yubikey: %v", err) - } - }() - - _, oerr := Open(card) - if oerr == nil { - t.Fatalf("expected second open operation to fail") - } - var e *scErr - if !errors.As(oerr, &e) { - t.Fatalf("expected scErr, got %v", oerr) - } - if e.rc != 0x8010000B { - t.Fatalf("expected return code 0x8010000B, got 0x%x", e.rc) - } - return - } - t.Skip("no yubikeys detected, skipping") -} - func TestYubiKeySerial(t *testing.T) { yk, close := newTestYubiKey(t) defer close()