跳至內容

Adding CLOUDHSM as a provider for use with keytool?

0

Hello,

I am trying to use keytool to import a working certificate into cloudHSM. I looked at https://docs.aws.amazon.com/cloudhsm/latest/userguide/using_keystore_with_keytool_5.html and https://docs.aws.amazon.com/cloudhsm/latest/userguide/import_working_cert_using_keytool_5.html but I am not able to get keytool to recognize the store type CLOUDHSM. I followed the instructions on https://docs.aws.amazon.com/cloudhsm/latest/userguide/keystore-prerequisites_5.html and added security.provider.10=com.amazonaws.cloudhsm.jce.provider.CloudHsmProvider to java.security.

When I try to list the providers using the following Java program, I do not see CLOUDHSM or anything remotely similar to that.

public class ListProviders {
    public static void main(String[] args) {
        for (Provider provider : Security.getProviders()) {
            System.out.println("Provider: " + provider.getName() + " (" + provider.getInfo() + ")");
            for (Provider.Service service : provider.getServices()) {
                if (service.getType().equals("KeyStore")) {
                    System.out.println("  KeyStore Type: " + service.getAlgorithm());
                }
            }
        }
    }
}

What am I missing?

Thank you, CK

已提問 1 年前檢視次數 157 次

1 個回答
0

When using keytool with AWS CloudHSM, you need to specify the CloudHSM key store type and Java classpath directly in your keytool command rather than expecting it to appear in your system's default providers list.

For keytool commands with AWS CloudHSM, you should include these specific arguments:

For Linux:

-storetype CLOUDHSM -J-classpath '-J/opt/cloudhsm/java/*'

For Windows:

-storetype CLOUDHSM -J-classpath '-J"C:\Program Files\Amazon\CloudHSM\java\*"'

The CloudHSM provider isn't registered as a standard KeyStore provider that would appear in your provider list. Instead, the -J-classpath argument dynamically adds the CloudHSM Java libraries to the classpath when keytool runs, making the CLOUDHSM store type available for that specific command execution.

For example, to import a certificate, your full command would look like:

keytool -importcert -noprompt -alias <key pair label> \
-file my_certificate.crt \
-keystore example_keystore.store \
-storetype CLOUDHSM \
-J-classpath '-J/opt/cloudhsm/java/*'

This approach allows keytool to recognize and use the CLOUDHSM store type for that specific command execution without requiring it to be permanently registered in your system's provider list.
Sources
Use AWS CloudHSM key store with keytool using Client SDK 5 - AWS CloudHSM
Import a working certificate into AWS CloudHSM key store using keytool - AWS CloudHSM

已回答 1 年前

  • The keytool command mentioned above throws the following error which leads me to believe that the keytool is expecting the Keystore to already exist. There is no information in the documentation to create this keystore. keytool error: java.security.KeyStoreException: CLOUDHSM not found

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。