Search code examples
javahsm

How can I mock a hardware secure module (HSM) in Java for a security provide?


In our project we are using an openID connect implementation. The implementation takes care of creating and signing JWTs. They use the nimbus-jose-jwt library for this.

I want to test if we add a HSM as a security provider if it will get used by the openId connect implementation. I don't have a machine with a HSM for testing purposes so I need to mock this behaviour.

Would I have to implement a Provider like in HowToImplAProvider (or use a library that did this) or is there a shortcut to have something that behaves like a Provider just for testing purposes?


Solution

  • I used the Windows build of SoftHSM2 (can be found here) and then used this answer to add it to my project.