mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-05 01:25:39 -05:00
added more debug info in msg validation code
This commit is contained in:
parent
bb7d8297ee
commit
e883a32711
@ -799,41 +799,52 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, const uin
|
||||
RsGxsMsgMetaData& metaData = *(msg->metaData);
|
||||
|
||||
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>::iterator mit = keys.begin();
|
||||
std::map<RsGxsId, RsTlvPublicRSAKey>& keys = grpKeySet.public_keys;
|
||||
std::map<RsGxsId, RsTlvPublicRSAKey>::iterator mit = keys.begin();
|
||||
|
||||
RsGxsId keyId;
|
||||
for(; mit != keys.end() ; ++mit)
|
||||
{
|
||||
RsTlvPublicRSAKey& key = mit->second;
|
||||
RsGxsId keyId;
|
||||
for(; mit != keys.end() ; ++mit)
|
||||
{
|
||||
RsTlvPublicRSAKey& key = mit->second;
|
||||
|
||||
if(key.keyFlags & RSTLV_KEY_DISTRIB_PUBLIC_deprecated)
|
||||
{
|
||||
keyId = key.keyId;
|
||||
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;
|
||||
break ;
|
||||
}
|
||||
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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(key.keyFlags & RSTLV_KEY_DISTRIB_PUBLIC_deprecated)
|
||||
{
|
||||
keyId = key.keyId;
|
||||
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;
|
||||
break ;
|
||||
}
|
||||
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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!keyId.isNull())
|
||||
{
|
||||
RsTlvPublicRSAKey& key = keys[keyId];
|
||||
publishValidate &= GxsSecurity::validateNxsMsg(*msg, sign, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
publishValidate = false;
|
||||
}
|
||||
}
|
||||
if(!keyId.isNull())
|
||||
{
|
||||
RsTlvPublicRSAKey& key = keys[keyId];
|
||||
publishValidate &= GxsSecurity::validateNxsMsg(*msg, sign, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
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
|
||||
{
|
||||
publishValidate = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user