mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed showup of self signatures in certificates that are not in the keyring already
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5438 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8b7f71b284
commit
9f7d54f91d
@ -82,10 +82,7 @@ PGPHandler::PGPHandler(const std::string& pubring, const std::string& secring,co
|
||||
RsStackFileLock flck(_pgp_lock_filename) ; // lock access to PGP directory.
|
||||
|
||||
if(_passphrase_callback == NULL)
|
||||
{
|
||||
std::cerr << "WARNING: before created a PGPHandler, you need to init the passphrase callback using PGPHandler::setPassphraseCallback()" << std::endl;
|
||||
exit(-1) ;
|
||||
}
|
||||
|
||||
// Allocate public and secret keyrings.
|
||||
//
|
||||
@ -220,7 +217,7 @@ bool PGPHandler::validateAndUpdateSignatures(PGPCertificateInfo& cert,const ops_
|
||||
ops_boolean_t res = ops_validate_key_signatures(result,keydata,_pubring,cb_get_passphrase) ;
|
||||
|
||||
if(res == ops_false)
|
||||
std::cerr << "(EE) Error in PGPHandler::validateAndUpdateSignatures(). Validation failed for at least some signatures." << std::endl;
|
||||
std::cerr << "(WW) Error in PGPHandler::validateAndUpdateSignatures(). Validation failed for at least some signatures." << std::endl;
|
||||
|
||||
bool ret = false ;
|
||||
|
||||
@ -627,16 +624,25 @@ bool PGPHandler::getGPGDetailsFromBinaryBlock(const unsigned char *mem_block,siz
|
||||
}
|
||||
|
||||
if(res == ops_false)
|
||||
std::cerr << "(EE) Error in PGPHandler::validateAndUpdateSignatures(). Validation failed for at least some signatures." << std::endl;
|
||||
std::cerr << "(WW) Error in PGPHandler::validateAndUpdateSignatures(). Validation failed for at least some signatures." << std::endl;
|
||||
|
||||
// also add self-signature if any (there should be!).
|
||||
//
|
||||
res = ops_validate_key_signatures(result,&tmp_keyring->keys[0],tmp_keyring,cb_get_passphrase) ;
|
||||
|
||||
if(res == ops_false)
|
||||
std::cerr << "(WW) Error in PGPHandler::validateAndUpdateSignatures(). Validation failed for at least some signatures." << std::endl;
|
||||
|
||||
// Parse signers.
|
||||
//
|
||||
|
||||
std::set<std::string> signers_set ; // Use a set to remove duplicates.
|
||||
|
||||
if(result != NULL)
|
||||
for(size_t i=0;i<result->valid_count;++i)
|
||||
{
|
||||
std::string signer_str = PGPIdType(result->valid_sigs[i].signer_id).toStdString() ;
|
||||
signers.push_back(signer_str) ;
|
||||
signers_set.insert(signer_str) ;
|
||||
}
|
||||
|
||||
ops_validate_result_free(result) ;
|
||||
@ -644,6 +650,13 @@ bool PGPHandler::getGPGDetailsFromBinaryBlock(const unsigned char *mem_block,siz
|
||||
ops_keyring_free(tmp_keyring) ;
|
||||
free(tmp_keyring) ;
|
||||
|
||||
// write to the output variable
|
||||
|
||||
signers.clear() ;
|
||||
|
||||
for(std::set<std::string>::const_iterator it(signers_set.begin());it!=signers_set.end();++it)
|
||||
signers.push_back(*it) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
#include <fstream>
|
||||
#include <string.h>
|
||||
|
||||
#include "argstream.h"
|
||||
//#include <pqi/cleanupxpgp.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <pgp/rscertificate.h>
|
||||
#include <pgp/pgphandler.h>
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
@ -64,6 +67,21 @@ int main(int argc,char *argv[])
|
||||
std::cerr << "Output from certificate (new format):" << std::endl;
|
||||
std::cerr << cert.toStdString() << std::endl ;
|
||||
|
||||
std::string key_id ;
|
||||
std::string name ;
|
||||
std::list<std::string> signers ;
|
||||
|
||||
PGPHandler handler("toto1","toto2","toto3","toto4") ;
|
||||
handler.getGPGDetailsFromBinaryBlock(cert.pgp_key(),cert.pgp_key_size(),key_id,name,signers) ;
|
||||
|
||||
std::cerr << "Details loaded from certificate:" << std::endl;
|
||||
std::cerr << "PGP id\t: " << key_id << std::endl;
|
||||
std::cerr << "Key name\t: " << name << std::endl;
|
||||
std::cerr << "Signers\t:" << std::endl;
|
||||
|
||||
for(std::list<std::string>::const_iterator it(signers.begin());it!=signers.end();++it)
|
||||
std::cerr << " " << *it << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch(std::exception& e)
|
||||
|
@ -260,7 +260,18 @@ void ConnectFriendWizard::initializePage(int id)
|
||||
QString ts;
|
||||
std::list<std::string>::iterator it;
|
||||
for (it = peerDetails.gpgSigners.begin(); it != peerDetails.gpgSigners.end(); ++it) {
|
||||
ts += QString("%1<%2>\n").arg(QString::fromUtf8(rsPeers->getPeerName(*it).c_str()), QString::fromStdString(*it));
|
||||
{
|
||||
std::string peer_name = rsPeers->getPeerName(*it) ;
|
||||
|
||||
// This is baaaad code. We should handle this kind of errors with proper exceptions.
|
||||
// This happens because signers from a unknown key cannt be found in the keyring, including
|
||||
// self-signatures.
|
||||
//
|
||||
if(peer_name == "[Unknown PGP Cert name]" && *it == peerDetails.gpg_id)
|
||||
peer_name = peerDetails.name ;
|
||||
|
||||
ts += QString("%1<%2>\n").arg(QString::fromUtf8(peer_name.c_str()), QString::fromStdString(*it));
|
||||
}
|
||||
}
|
||||
|
||||
ui->nameEdit->setText(QString::fromUtf8(peerDetails.name.c_str()));
|
||||
|
Loading…
Reference in New Issue
Block a user