I know what you are experimenting :)
The best way is to ask to HID what are the required attributes.
This is the snippet to load a certificate:
Function ImportCertificate(ByVal session As Session, ByVal cert As X509Certificate2, ByVal id As String, ByVal label As String, ByVal modifiable As Boolean) As CryptokiObject
Dim template As CryptokiCollection
Dim certif As Certificate
template = New CryptokiCollection()
template.Add(New ObjectAttribute(ObjectAttribute.CKA_CLASS, CryptokiObject.CKO_CERTIFICATE))
template.Add(New ObjectAttribute(ObjectAttribute.CKA_SUBJECT, cert.SubjectName.RawData))
template.Add(New ObjectAttribute(ObjectAttribute.CKA_ISSUER, cert.Issuer))
template.Add(New ObjectAttribute(ObjectAttribute.CKA_SERIAL_NUMBER, cert.SerialNumber))
template.Add(New ObjectAttribute(ObjectAttribute.CKA_ID, id))
template.Add(New ObjectAttribute(ObjectAttribute.CKA_LABEL, label))
template.Add(New ObjectAttribute(ObjectAttribute.CKA_TOKEN, True))
template.Add(New ObjectAttribute(ObjectAttribute.CKA_VALUE, cert.RawData))
template.Add(New ObjectAttribute(ObjectAttribute.CKA_MODIFIABLE, modifiable))
certif = session.Objects.Create(template)
ImportCertificate = certif
End Function
Regards,
Ugo