Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

engine causes segmantation fault #2

Closed
jetbee opened this issue Dec 1, 2021 · 5 comments
Closed

engine causes segmantation fault #2

jetbee opened this issue Dec 1, 2021 · 5 comments

Comments

@jetbee
Copy link

jetbee commented Dec 1, 2021

Hello,
Thanks for great work.

I've tried to use this engine.
At first, I examined your nginx example.
I've do as followed the document sequence.
Then, it occured Segmentation Fault.
Is my procedure is wrong?
Thanks.

  • If run command with $1 (as documented) cause an error below:
root@tubuntu:~# openssl req -new -x509 -engine e_akv -keyform engine -key vault:
$1:test-rsa-key -out cert.pem
engine "e_akv" set.
cannot load Private Key from engine
139940651017536:error:8010E102:lib(128):akv_load_key_cert:parse key id error:/us
r/local/src/AzureKeyVaultManagedHSMEngine-main/src/dllmain.c:177:
139940651017536:error:26096080:engine routines:ENGINE_load_private_key:failed lo
ading private key:../crypto/engine/eng_pkey.c:77:
unable to load Private Key
  • is $1 points HSM name?
  • Then, replace $1 to HSM name cause Segmentation Fault.
root@tubuntu:~# openssl req -new -x509 -engine e_akv -keyform engine -key vault:
managed-hsm-for-tsa:test-rsa-key -out cert.pem
engine "e_akv" set.
Segmentation fault (core dumped)
@liupums
Copy link
Member

liupums commented Dec 2, 2021

in the engine, vault is for azure key vault. If you created a key in HSM, please use managedHsm as the prefix. I am adding the Managed HSM example soon.

@liupums
Copy link
Member

liupums commented Dec 2, 2021

  1. the HSM example is available https://github.com/microsoft/AzureKeyVaultManagedHSMEngine/blob/main/samples/nginx-managedHsm/readme.md
  2. I was trying to reproduce the core dump, but no luck. If the prefix "vault" is used for an existing HSM, what I got is
azureuser@hsmlinux:~/AzureKeyVaultManagedHSMEngine/samples/nginx-managedHsm$ openssl req -new -x509 -engine e_akv -keyform engine -key vault:poptryhsmengine:tescckey -out certecc.pem
engine "e_akv" set.
[e] AkvGetKey curl.c(400) curl_easy_perform() failed: Couldn't resolve host name

cannot load Private Key from engine
140637073995072:error:8010E103:lib(128):akv_load_key_cert:load public key error:/home/azureuser/AzureKeyVaultManagedHSMEngine/src/dllmain.c:203:
140637073995072:error:26096080:engine routines:ENGINE_load_private_key:failed loading private key:../crypto/engine/eng_pkey.c:77:
unable to load Private Key

I noticed that in your error message, there is no

[e] AkvGetKey curl.c(400) curl_easy_perform() failed: Couldn't resolve host name

Maybe you are using the old code, could you pull the latest code and rebuild/retry?

@liupums liupums closed this as completed Dec 4, 2021
@liupums
Copy link
Member

liupums commented Dec 4, 2021

not reproduceable

@jetbee
Copy link
Author

jetbee commented Dec 6, 2021

Thanks for new example.
I've run the command step by step.
Then, It worked!
Thank you very much!

And in my environment some commands occured errors.
There's my corrections:

(1)

openssl req -newkey rsa:2048 -nodes -keyout cert_1.key -x509 -days 365 -out cert_1.cer -config openssl.cnf

In my windows 10 environment, I can use default openssl.cnf as not specified.

openssl req -newkey rsa:2048 -nodes -keyout cert_1.key -x509 -days 365 -out cert_1.cer

(2)
before run this command:

az keyvault key create --curve p-256 --kty EC-HSM --name testecckey --hsm-name [HSM NAME] --ops sign

In my case it was nesessary to assign hsm local role to my account via this command:

az keyvault role assignment create --hsm-name [HSM NAME] --assignee xxx --scope / --role "Managed HSM Crypto User"

(3)

maybe p-256 is mistyped of P-256

az keyvault key create --curve P-256 --kty EC-HSM --name testecckey --hsm-name [HSM NAME] --ops sign

@liupums
Copy link
Member

liupums commented Dec 6, 2021

(1) the sample openssl.cnf is provided in the repo
(2) this is a good point.
(3) p-256 should work (it is case-insensitive)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants