Bug #3438
closedInvalid default certificate created for existing default key of an identity
100%
Description
When an identity has a default key, but no associated certificate, signing with the identity will result in generating another key and self-signed certificate. Instead, a self-signed certificate should be created in this case.
To reproduce issue (http://gerrit.named-data.net/#/c/2692/1/tests/unit-tests/security/key-chain.t.cpp@422),
KeyChain keyChain;
Name ecdsaIdentity = Name("/ndn/test/ecdsa").appendVersion();
Name ecdsaKeyName = keyChain.generateEcdsaKeyPairAsDefault(ecdsaIdentity, false, 256);
BOOST_CHECK_NO_THROW(keyChain.sign(data, signingByIdentity(ecdsaIdentity)));
BOOST_CHECK_EQUAL(data.getSignature().getType(),
KeyChain::getSignatureType(EcdsaKeyParams().getKeyType(), DIGEST_ALGORITHM_SHA256));
BOOST_CHECK(ecdsaIdentity.isPrefixOf(data.getSignature().getKeyLocator().getName()));
if no certificate is available for the default key and its type does not corresponds to the DEFAULT_KEY_PARAMS
a new pair of DEFAULT_KEY_PARAMS
keys is created, set as default and used for
signing. Solved by checking the type of key of the default key pair for the identity.
Updated by Alex Afanasyev almost 9 years ago
- Status changed from New to Code review
Updated by Junxiao Shi almost 9 years ago
I'm able to reproduce this issue on command line.
ndnsec-keygen -tr /X > X.req
creates a certificate requestndnsec-keygen -te /Y > /dev/null
creates an ECDSA key and sets it as default, but there's no certificatendnsec-certgen -N 'XX' -r X.req > /dev/null
signs X.req with default identity/Y
ndnsec-list -C
shows/Y
has two keys now, and the new key has a self-signed RSA certificate
But this issue occurs only when I specify ECDSA key in step2. This is probably due to the default being RSA.
Updated by José Quevedo almost 9 years ago
The issue with ndnsec-certgen is similar to the one found in KeyChain:
- In the absence of a certificate KeyChain::createIdentity is called, specifying only the identityName, thus assuming params as DEFAULT_KEY_PARAMS.
- In KeyChain::createIdentity, since the type of the default key for the identity does not match the type in DEFAULT_KEY_PARAMS (RSA), a new ksk key is created using DEFAULT_KEY_PARAMS and set as default for the identity.
Updated by Alex Afanasyev over 8 years ago
- Status changed from Code review to Closed