mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-06 05:14:21 -04:00
added more debug info in msg validation code
This commit is contained in:
parent
bb7d8297ee
commit
e883a32711
1 changed files with 42 additions and 31 deletions
|
@ -799,41 +799,52 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, const uin
|
||||||
RsGxsMsgMetaData& metaData = *(msg->metaData);
|
RsGxsMsgMetaData& metaData = *(msg->metaData);
|
||||||
|
|
||||||
if(needPublishSign)
|
if(needPublishSign)
|
||||||
{
|
{
|
||||||
RsTlvKeySignature sign = metaData.signSet.keySignSet[INDEX_AUTHEN_PUBLISH];
|
RsTlvKeySignature sign = metaData.signSet.keySignSet[INDEX_AUTHEN_PUBLISH];
|
||||||
|
|
||||||
std::map<RsGxsId, RsTlvPublicRSAKey>& keys = grpKeySet.public_keys;
|
std::map<RsGxsId, RsTlvPublicRSAKey>& keys = grpKeySet.public_keys;
|
||||||
std::map<RsGxsId, RsTlvPublicRSAKey>::iterator mit = keys.begin();
|
std::map<RsGxsId, RsTlvPublicRSAKey>::iterator mit = keys.begin();
|
||||||
|
|
||||||
RsGxsId keyId;
|
RsGxsId keyId;
|
||||||
for(; mit != keys.end() ; ++mit)
|
for(; mit != keys.end() ; ++mit)
|
||||||
{
|
{
|
||||||
RsTlvPublicRSAKey& key = mit->second;
|
RsTlvPublicRSAKey& key = mit->second;
|
||||||
|
|
||||||
if(key.keyFlags & RSTLV_KEY_DISTRIB_PUBLIC_deprecated)
|
if(key.keyFlags & RSTLV_KEY_DISTRIB_PUBLIC_deprecated)
|
||||||
{
|
{
|
||||||
keyId = key.keyId;
|
keyId = key.keyId;
|
||||||
std::cerr << "WARNING: old style publish key with flags " << key.keyFlags << std::endl;
|
std::cerr << "WARNING: old style publish key with flags " << key.keyFlags << std::endl;
|
||||||
std::cerr << " this cannot be fixed, but RS will deal with it." << std::endl;
|
std::cerr << " this cannot be fixed, but RS will deal with it." << std::endl;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
if(key.keyFlags & RSTLV_KEY_DISTRIB_PUBLISH) // we might have the private key, but we still should be able to check the signature
|
if(key.keyFlags & RSTLV_KEY_DISTRIB_PUBLISH) // we might have the private key, but we still should be able to check the signature
|
||||||
{
|
{
|
||||||
keyId = key.keyId;
|
keyId = key.keyId;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!keyId.isNull())
|
if(!keyId.isNull())
|
||||||
{
|
{
|
||||||
RsTlvPublicRSAKey& key = keys[keyId];
|
RsTlvPublicRSAKey& key = keys[keyId];
|
||||||
publishValidate &= GxsSecurity::validateNxsMsg(*msg, sign, key);
|
publishValidate &= GxsSecurity::validateNxsMsg(*msg, sign, key);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
publishValidate = false;
|
std::cerr << "(EE) public publish key not found in group that require publish key validation. This should not happen! msgId=" << metaData.mMsgId << ", grpId=" << metaData.mGroupId << std::endl;
|
||||||
}
|
std::cerr << "(EE) public keys available for this group are: " << std::endl;
|
||||||
}
|
|
||||||
|
for(std::map<RsGxsId, RsTlvPublicRSAKey>::const_iterator it(grpKeySet.public_keys.begin());it!=grpKeySet.public_keys.end();++it)
|
||||||
|
std::cerr << "(EE) " << it->first << std::endl;
|
||||||
|
|
||||||
|
std::cerr << "(EE) private keys available for this group are: " << std::endl;
|
||||||
|
|
||||||
|
for(std::map<RsGxsId, RsTlvPrivateRSAKey>::const_iterator it(grpKeySet.private_keys.begin());it!=grpKeySet.private_keys.end();++it)
|
||||||
|
std::cerr << "(EE) " << it->first << std::endl;
|
||||||
|
|
||||||
|
publishValidate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
publishValidate = true;
|
publishValidate = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue