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