Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C_GetInfo() to p11-kit-client.so returns empty object #156

Open
andsens opened this issue Jan 8, 2024 · 3 comments
Open

C_GetInfo() to p11-kit-client.so returns empty object #156

andsens opened this issue Jan 8, 2024 · 3 comments

Comments

@andsens
Copy link

andsens commented Jan 8, 2024

image

I don't exactly know why this happens, but it becomes a breaking bug in graphene.
removePadding(text: string) specifically cannot handle undefined as a parameter.

I tried making a patch for this, but I'm not really sure where this should be handled idiomatically.

For now I'm just patching core/type.ts:

diff --git a/src/core/type.ts b/src/core/type.ts
index 1b3c2b0..e0eb075 100644
--- a/src/core/type.ts
+++ b/src/core/type.ts
@@ -84,5 +84,5 @@ export function isFlag(v: number, fv: number) {
  * @param text Formatted string
  */
 export function removePadding(text: string) {
-  return text.replace(/\0.*/g, "").trim();
+  return text ? text.replace(/\0.*/g, "").trim() : text;
 }
@andsens
Copy link
Author

andsens commented Jan 8, 2024

Oh, and let's add the actual error message so people can find it by searching for just that :-)

TypeError: Cannot read properties of undefined (reading 'replace')

@microshine
Copy link
Contributor

It seems that the issue might not lie with graphene, but rather with pkcs11js. Based on the script you've shared, it appears that the C_GetInfo function is returning an empty object. This shouldn't be the case, as there should definitely be a structure returned. We need to understand why this is happening. What version of nodejs are you using? pkcs11js is a C plugin for nodejs that gets compiled during the module installation. It's possible that there have been changes in the native API, causing the module to not function as expected.

@andsens
Copy link
Author

andsens commented Jan 8, 2024

Oh I figured as much. I still wanted to create a ticket here to highlight an opportunity for a little error resilience :-)

This is running in a container base on node:20.2.0-bullseye and then just installing the debian p11-kit package (repo says the version is 0.23.22-1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants