-
Hi, I am using EJBCA as a lab PKI for close to 2 years by now. Recently I managed to obtain a HSM and my first thought was to make use of it for EJBCA.
However, the key was created on the HSM
I am using OpenJDK 11.0.17, EJBCA CE 7.10.0.2, NitroKey HSM 2. Is this HSM supported by EJBCA CE? Am I using the wrong command? Any hint would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 17 comments 27 replies
-
Hello, I stumbled upon the same issue with SunPKCS11(used by EJBCA CE) and NitroKey recently. However, I never got the the bottom of it. Will let you know if I make any progress. |
Beta Was this translation helpful? Give feedback.
-
I am able to produce log files using p11spy, but I don't feel confident interpreting the output. As far as I can see the results are opposite of what I expected. for Java 11.0.2 I get:
but for Java 11.0.17 I get:
which seems to me that .17 has more mechanisms available than .2 - I expected the mechanisms to be missing on the .17 side. The only thing I see missing on .17 is:
I can see these "new" algorithms on .17:
I'm a bit at loss for what to look out for and what to check for. What could be the next step? |
Beta Was this translation helpful? Give feedback.
-
Sorry for the delay. I can now present logs from a reproducible test setup. I have produced logs for Java 11.0.2 and 11.0.17. We can see a difference in size and 11.0.17 has much longer list of mechanisms. Java 11.0.2: working -> pkcs11spy_java11.0.2.log If the logs contain sensitive material/credentials, those are not in use outside of the test setup. Do you have any idea what is going on there? I would have expected the 11.0.17 log to actually be shorter and missing things, but it seems to be the opposite. One idea: the 11.0.17 setup lists broken mechanisms and the test button choses those and breaks. In the 11.0.2 setup it choses a different, but working mechanism. |
Beta Was this translation helpful? Give feedback.
-
We used the "test" Button on the Cryptotokens Interface of the EJBA Administation WebUI. It should compare to your "clientToolBox.sh" command. The key generation in the cryptotoken Interface also fails, but we did not provide logs for that. I will try to find time to create logs for the "cryptotoken createn" case too. |
Beta Was this translation helpful? Give feedback.
-
This means modifying the Dockerfile to create "-devel" container variants first. I will do that, but I cannot promise results for this week, but I will try. |
Beta Was this translation helpful? Give feedback.
-
I will give it a try |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I'm only noticing references to I notice the comments in discussion 100 to be very similar and a release of 7.10.1 was promised to address such an issue. We're testing with 7.11. I do not know if those are related. |
Beta Was this translation helpful? Give feedback.
-
I think it is fair to say that we (my coworker and me) do feel with you regarding the pain with debugging p11. And it's always difficult to share enough but not too much information. We actually had a look into the enterprise version of EJBCA a while ago, but never came to a final conclusion/solution/negotiation for reasons currently unknown to me. I think there was outstanding communication that we were waiting for or something, I'm not sure. I'm only responsible for technical aspects. Still, I cannot wrap my head around what exactly gets broken between java 11.0.2->.17 so bad that this breaks the application. From my experience I'd say that something is filtering available compatible methods/algorithms and the final list of available options does not match (e.g. "can be used for signing" missing etc) or another new but incompatible algorithm is being offered and chosen over the one that we'd want. I was not able to tell this from the P11 output. Is there anything further that we can assist with? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the thorough analysis. I will try to find time to look into this again. I think I remember opensc/pkcs11/java to allow for configuration files for overriding aspects. I think I've seen such overrides for some other HSM implementation. |
Beta Was this translation helpful? Give feedback.
-
I've been trying to wrap my mine around this once more, but I'm unable to make progress. Writing a configuration file with attributes for opensc did not improve things, albeit I only tried attribute(,...PRIVATE...,) { CKA_ENCRYPT = true} and actually have not much knowledge how this integrates. So the idea of overriding things with "Accept that this always supports encryption" seems to be a dead end for me right now. I've tries using the smartcard-hsm driver which seems to half-way work with pkcs15-tool, but produces "empty output" when used with wildfly+ejbca. Unfortunately I cannot map logfiles to attempts today and my concentration level isn't very high. Any other ideas? |
Beta Was this translation helpful? Give feedback.
-
I have just tried this using java -Dpkcs11.... as parameters to the wildfly startup (also seeing the parameter in the process list). This does not make a difference. My next plan is to contact the hardware vendor to verify they have implemented technical support for the required Mechanisms for CKF_ENCRYPT and really are just missing the flag. That way we will either be able to trace where it gets lost or will get added the required mechanisms if they're missing. Chances are that CKF_ENCRYPT hasn't been set because it works anyway (until you use a recent java) or that CKF_ENCRYPT has not been set because the C_encrypt... family of functions aren't completly implemented. I expect just a missing flag CKF_ENCRYPT because Java 11.0.2 would probably have been broken if the mechanisms weren't complete. We might need to reevaluate p11ng later. |
Beta Was this translation helpful? Give feedback.
-
I have internally escalated this issue in order to get vendor support and will cease to work on this issue until I have feedback. I expect this to cause a firmware update to our hardware for either the flag or adding functions. I do think that CKF_DECRYPT without CKF_ENCRYPT is really an invalid combination for RSA mechanmisms for the expected use cases of this hardware. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately that's one thing I tried already this week:
|
Beta Was this translation helpful? Give feedback.
-
No, it's fine. You're absolutely right with suggesting p11ng, I think it's the way to go for us. |
Beta Was this translation helpful? Give feedback.
-
Can you try the SmartCard-HSM specific PKCS#11 module from here ? While OpenSC reports
our module reports
Maybe that solves the issue. There is also a per key report of the capabilities and there only indicating CKF_DECRYPT is correct for a RSA private key. CKF_DECRYPT also has nothing to do with RSA signing, so it puzzles me why sunpkcs11 is confused. But anyway, sunpkcs11 does no have a good track record IMHO. That is why we recommend to use the native JCE Provider instead (not sure if that can be used with EJCBA though). |
Beta Was this translation helpful? Give feedback.
-
I was able to generate RSA keys on Nitrokey HSM with EJBCA CE 8.0 and Java 17 (17.0.8.0.2). However, Java options in |
Beta Was this translation helpful? Give feedback.
I was able to generate RSA keys on Nitrokey HSM with EJBCA CE 8.0 and Java 17 (17.0.8.0.2). However, Java options in
ejbcaClientToolBox.sh
must be amended with--add-exports=jdk.crypto.cryptoki/sun.security.pkcs11.wrapper=ALL-UNNAMED
in order for command to succeed.