You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using this awesome library to read a certificate and get the corresponding signer from a smartcard.
The smartcard contains 3 proper certificates (RSA).
However, the following code returns an empty slice:
allKeyPairs, err := c.FindAllKeyPairs()
if err != nil {
fmt.Errorf("error finding all key pairs", err)
}
fmt.Println("Number of key pairs ", len(allKeyPairs))
Now, I've found that for some reason there's a case where there is an unsupported key type (in file keys.go on line 209).
On the smartcard I can see a total of 13 objects (but I'm not a PKCS#11 expert so I don't really know what is going on in depth).
This unsupported key type in turn causes the loop in the function FindKeyPairsWithAttributes to return on line 232.
Replacing this return statement with a continue statement keeps the loop running and leads to the desired result (in my case a slice with 3 signer interfaces).
err = c.withSession(func(session *pkcs11Session) error {
// Add the private key class to the template to find the private half
privAttributes := attributes.Copy()
err = privAttributes.Set(CkaClass, pkcs11.CKO_PRIVATE_KEY)
if err != nil {
return err
}
privHandles, err := findKeysWithAttributes(session, privAttributes.ToSlice())
if err != nil {
return err
}
for _, privHandle := range privHandles {
k, err := c.makeKeyPair(session, &privHandle)
if err == errNoCkaId || err == errNoPublicHalf {
continue
}
if err != nil {
// keep looping in case of an unsupported key type
continue
//return err
}
keys = append(keys, k)
}
return nil
})
I can't judge if this should be fixed in this lib. If not, are there any workarounds? I basically need to read all certificates from the smartcard, choose the one with usage of clientauth and then get the corresponding singer to use the cert and the signer to perform a http client request.
Cheers,
Jan
The text was updated successfully, but these errors were encountered:
Hello,
I'm using this awesome library to read a certificate and get the corresponding signer from a smartcard.
The smartcard contains 3 proper certificates (RSA).
However, the following code returns an empty slice:
Now, I've found that for some reason there's a case where there is an unsupported key type (in file keys.go on line 209).
On the smartcard I can see a total of 13 objects (but I'm not a PKCS#11 expert so I don't really know what is going on in depth).
This unsupported key type in turn causes the loop in the function
FindKeyPairsWithAttributes
to return on line 232.Replacing this return statement with a continue statement keeps the loop running and leads to the desired result (in my case a slice with 3 signer interfaces).
I can't judge if this should be fixed in this lib. If not, are there any workarounds? I basically need to read all certificates from the smartcard, choose the one with usage of clientauth and then get the corresponding singer to use the cert and the signer to perform a http client request.
Cheers,
Jan
The text was updated successfully, but these errors were encountered: