diff --git a/libretroshare/src/pgp/pgphandler.cc b/libretroshare/src/pgp/pgphandler.cc index 470e967a3..6f9b0eaf1 100644 --- a/libretroshare/src/pgp/pgphandler.cc +++ b/libretroshare/src/pgp/pgphandler.cc @@ -835,7 +835,18 @@ bool PGPHandler::importGPGKeyPair(const std::string& filename,PGPIdType& importe ops_validate_key_signatures(result, const_cast(pubkey), &dummy_keyring, cb_get_passphrase) ; - if(result->valid_count != 1 || memcmp((unsigned char*)result->valid_sigs[0].signer_id,pubkey->key_id,KEY_ID_SIZE)) + // Check that signatures contain at least one certification from the user id. + // + bool found = false ; + + for(uint32_t i=0;ivalid_count;++i) + if(!memcmp((unsigned char*)result->valid_sigs[i].signer_id,pubkey->key_id,KEY_ID_SIZE)) + { + found = true ; + break ; + } + + if(!found) { import_error = "Cannot validate self signature for the imported key. Sorry." ; return false ; diff --git a/libretroshare/src/tests/pgp/test_identity_import.c b/libretroshare/src/tests/pgp/test_identity_import.c index 8992d0a54..7fcd14066 100644 --- a/libretroshare/src/tests/pgp/test_identity_import.c +++ b/libretroshare/src/tests/pgp/test_identity_import.c @@ -42,6 +42,8 @@ int main(int argc,char *argv[]) bool res = handler.importGPGKeyPair(idfile,imported_key_id,import_error_string) ; + handler.syncDatabase() ; + if(!res) std::cerr << "Identity Import error: " << import_error_string << std::endl;