Skip to content

Obtain .pem file for private key using softhsm2-dump-object #597

@tarruda

Description

@tarruda

Hi

I would like to export a private key stored in a .object file. I don't understand the format used used by SoftHSM to store private keys, but it seems to be possible to obtain all the relevant information using softhsm2-dump-object. Here's what I did after initializing an empty token:

# generate a keypair
pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --login --keypairgen --key-type rsa:512
# obtain the private key data, it is stored in "a2b0d15f..." object:
softhsm2-dump-file /var/lib/softhsm/tokens/810b3ea3-1b94-c997-d83c-e883739b455a/a2b0d15f-6a48-be50-e515-fe005be5a236.object

The above prints all relevant information about the private key to stdout. Do you know how can I convert that to a "PEM" file for using with openssl?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions