Skip to content

Commit 2a927d0

Browse files
committed
Ignore the empty OpenPGP token exposed by OpenSC with a Nitrokey 3
1 parent 862f470 commit 2a927d0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

jsign-core/src/main/java/net/jsign/OpenSC.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ static long getTokenSlot(File libraryPath, String name) throws PKCS11Exception,
9090
CK_SLOT_INFO info = pkcs11.C_GetSlotInfo(slot);
9191
String description = new String(info.slotDescription).trim();
9292
if (name == null || description.toLowerCase().contains(name.toLowerCase())) {
93+
CK_TOKEN_INFO tokenInfo = pkcs11.C_GetTokenInfo(slot);
94+
String label = new String(tokenInfo.label).trim();
95+
if (label.equals("OpenPGP card (User PIN (sig))")) {
96+
// OpenPGP cards such as the Nitrokey 3 are exposed as two slots with the same name by OpenSC.
97+
// Only the first one contains the signing key and the certificate, so the second one is ignored.
98+
continue;
99+
}
100+
93101
matches.add(slot);
94102
}
95103
descriptions.add(description);

0 commit comments

Comments
 (0)