3 C_GetSlotList false NULL slotCount
4 NewArray slotList CK_ULONG slotCount
5 C_GetSlotList false slotList slotCount
6 #change the following to the appropriate slot id
8 #set slotID slotList[0]
9 C_GetSlotInfo slotID slotInfo
10 C_GetTokenInfo slotID tokenInfo
11 C_OpenSession slotID CK_SESSION_SERIAL session
13 #uncomment the following line and include the correct password
14 #C_Login session CKU_USER 0000 4
16 # build the search template
18 NewTemplate search CKA_CLASS
19 SetTemplate search 0 CKO_CERTIFICATE
20 NewArray certID CK_ULONG 1
21 C_FindObjectsInit session search 1
22 C_FindObjects session certID 1 count
23 C_FindObjectsFinal session
25 # now read the cert out
27 NewTemplate derCert CKA_VALUE
28 C_GetAttributeValue session certID derCert 1
30 C_GetAttributeValue session certID derCert 1