Skip to content

how do I refer to a cloudhsm key when using openssl

0

I want to create a CSR using openssl. I'm using this command:

openssl req -engine cloudhsm -keyform engine -new -out my-request.csr -subj "/CN=Acme, Inc./O=example.com" -key "cloudhsm:handle=1"

I don't know if the value I'm using for -key is correct, where to find a handle, or where any of this is documented.

asked 2 years ago384 views

1 Answer
0

To refer to a CloudHSM key when using OpenSSL, you need to use the CloudHSM dynamic engine for OpenSSL. Your command is on the right track, but let's clarify a few points:

  1. The -engine cloudhsm option is correct. This tells OpenSSL to use the CloudHSM dynamic engine.

  2. For the -key option, you're close, but the format needs a slight adjustment. Instead of "cloudhsm:handle=1", you should use the format "handle:key_handle". For example: "-key handle:1".

The key handle is a unique identifier for your key in the HSM. You'll need to know this handle beforehand. Unfortunately, the OpenSSL command itself doesn't provide a way to list or find key handles.

To find the key handle, you would typically use the CloudHSM management utilities or APIs. For instance, you might use the CloudHSM CLI to list keys and their handles.

It's worth noting that while OpenSSL with the CloudHSM engine is powerful, it may not be the most straightforward method for generating a CSR. An alternative approach could be to use the keytool utility with the AWS CloudHSM keystore, which provides a more integrated experience with CloudHSM.

If you decide to stick with OpenSSL, make sure you have properly set up the CloudHSM client and configured the OpenSSL dynamic engine before running your command. The shared library for the dynamic engine should be located at /opt/cloudhsm/lib/libcloudhsm_openssl.so on your system.
Sources
Use the OpenSSL Dynamic Engine for AWS CloudHSM Client SDK 3 - AWS CloudHSM
Generate an AWS CloudHSM CSR using keytool - AWS CloudHSM

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.