From c0acb711367aaab2679d9ad6d9ae563349b85753 Mon Sep 17 00:00:00 2001 From: joss17 Date: Tue, 19 Jan 2010 21:44:59 +0000 Subject: [PATCH] add the clean cert routine for gpg certs git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2090 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/authgpg.cc | 7 ++++++- libretroshare/src/pqi/cleanupxpgp.cc | 16 +++++++++++++++- .../src/gui/connect/ConnectFriendWizard.cpp | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index e01aa1d72..b1046c4bd 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -30,6 +30,7 @@ #include #include #include "serialiser/rsconfigitems.h" +#include "cleanupxpgp.h" // initialisation du pointeur de singleton à zéro @@ -1201,8 +1202,12 @@ bool AuthGPG::LoadCertificateFromString(std::string str, std::string &gpg_id) RsStackMutex stack(pgpMtx); /******* LOCKED ******/ + std::string cleancert = cleanUpCertificate(str); + + std::cerr << "AuthGPG::LoadCertificateFromString() cleancert : " << cleancert; + gpgme_data_t gpgmeData; - if (GPG_ERR_NO_ERROR != gpgme_data_new_from_mem(&gpgmeData, str.c_str(), str.length(), 1)) + if (GPG_ERR_NO_ERROR != gpgme_data_new_from_mem(&gpgmeData, cleancert.c_str(), cleancert.length(), 1)) { std::cerr << "Error create Data"; std::cerr << std::endl; diff --git a/libretroshare/src/pqi/cleanupxpgp.cc b/libretroshare/src/pqi/cleanupxpgp.cc index 99b7077ea..45e1a954c 100644 --- a/libretroshare/src/pqi/cleanupxpgp.cc +++ b/libretroshare/src/pqi/cleanupxpgp.cc @@ -224,7 +224,21 @@ std::string cleanUpCertificate(std::string badCertificate) while(badCertificate[currBadCertIdx]=='\n'|| badCertificate[currBadCertIdx]==' ') { currBadCertIdx++; - } + } + + //keep the first line : gnupg version + cleanCertificate[currCleanCertIdx]= badCertificate[currBadCertIdx]; + currBadCertIdx++; + while(badCertificate[currBadCertIdx]!='\n') + { + cleanCertificate[currCleanCertIdx]= badCertificate[currBadCertIdx]; + currCleanCertIdx++; + currBadCertIdx++; + } + cleanCertificate[currCleanCertIdx]= badCertificate[currBadCertIdx]; + currCleanCertIdx++; + currBadCertIdx++; + //Start of the actual certificate. Remove spaces in the certificate //and make sure there are 64 characters per line in the //new cleaned certificate diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 9ff87c8fa..dc60ca755 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -813,7 +813,7 @@ void ConclusionPage::initializePage() { //set the radio button to sign the GPG key if (detail.accept_connection && !detail.ownsign) { //gpg key connection is already accepted, don't propose to accept it again - signGPGRadioButton->setText(tr("Peer is already a GPG key is already a retroshare friend. Sign his GPG key.")); + signGPGRadioButton->setText(tr("Peer is already a retroshare friend. Sign his GPG key.")); signGPGRadioButton->setChecked(true); acceptNoSignGPGRadioButton->hide(); acceptNoSignGPGRadioButton->setChecked(false);