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

xmlsec-openssl: check if key matches key cert when loading from memory or file; fix no-x509 build #586

Merged
merged 6 commits into from
Mar 6, 2023

Conversation

lsh123
Copy link
Owner

@lsh123 lsh123 commented Mar 6, 2023

No description provided.

@lsh123 lsh123 changed the title xmlsec-openssl: check if key matches key cert when loading from memory or file xmlsec-openssl: check if key matches key cert when loading from memory or file; fix no-x509 build Mar 6, 2023
@beldmit
Copy link

beldmit commented Mar 6, 2023

I'm not sure that it will work for HW-backed keys so at least on the API level it's worth having a flag skipping this check.

@lsh123
Copy link
Owner Author

lsh123 commented Mar 6, 2023

I'm not sure that it will work for HW-backed keys so at least on the API level it's worth having a flag skipping this check.

If this check fails then we simply add the cert to the key w/o marking it as "key cert". I think this is correct because if we can't be sure that key matches cert, then we shouldn't designate it as key cert.

Moreover, I am now even sure if the HW keys check will fail given that this is checking public keys.

@lsh123
Copy link
Owner Author

lsh123 commented Mar 6, 2023

@beldmit

Looks like it works for SOFTHSM at least (--verify-keys requires key cert):

SOFTHSM2_CONF=./softhsm.conf softhsm2-util --slot 0 --label test --init-token --pin secret1 --so-pin secret2
SOFTHSM2_CONF=./softhsm.conf pkcs11-tool --usage-derive --module /usr/lib/softhsm/libsofthsm2.so --login --write-object ../tests/keys/largersakey.pem  -y privkey --label key2 --pin secret1


SOFTHSM2_CONF=./softhsm.conf ./apps/xmlsec1 sign --verify-keys  --privkey-openssl-engine:largersakey  "pkcs11;pkcs11:token=test;object=key2;pin-value=secret1,../tests/keys/largersacert.pem" --untrusted-pem ../tests/keys/ca2cert.pem --trusted-pem ../tests/keys/cacert.pem  ../tests/aleksey-xmldsig-01/enveloped-sha1-rsa-sha1.tmpl 

>> works!

@lsh123 lsh123 merged commit 045c12f into master Mar 6, 2023
@lsh123 lsh123 deleted the openssl-check-key-cert branch March 6, 2023 21:33
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

Successfully merging this pull request may close these issues.

2 participants