mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 16:39:29 -05:00
return false when ssl passphrase is of length 0. This should not happen, unless the file is void, since openpgp does not complain about decrypting empty files
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5343 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0d72ad1806
commit
2440b2d74a
@ -635,21 +635,6 @@ bool RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(const std::string& ssl_id
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sslPassphraseFile = RsDirUtil::rs_fopen(getSSLPasswdFileName(ssl_id).c_str(), "w");
|
|
||||||
|
|
||||||
// if(sslPassphraseFile == NULL)
|
|
||||||
// {
|
|
||||||
// std::cerr << "RsLoginHandler::storeSSLPasswdIntoGPGFile(): could not write to file " << getSSLPasswdFileName(ssl_id) << std::endl;
|
|
||||||
// return false ;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// std::cerr << "openned sslPassphraseFile : " << getSSLPasswdFileName(ssl_id) << std::endl;
|
|
||||||
//
|
|
||||||
// gpgme_data_t cipher;
|
|
||||||
// gpgme_data_t plain;
|
|
||||||
// gpgme_data_new_from_mem(&plain, ssl_passwd.c_str(), ssl_passwd.length(), 1);
|
|
||||||
// gpgme_data_new_from_stream (&cipher, sslPassphraseFile);
|
|
||||||
|
|
||||||
bool ok ;
|
bool ok ;
|
||||||
std::string cipher ;
|
std::string cipher ;
|
||||||
|
|
||||||
@ -664,10 +649,6 @@ bool RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(const std::string& ssl_id
|
|||||||
ok= false ;
|
ok= false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gpgme_data_release (cipher);
|
|
||||||
// gpgme_data_release (plain);
|
|
||||||
// fclose(sslPassphraseFile);
|
|
||||||
|
|
||||||
return ok ;
|
return ok ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,37 +667,18 @@ bool RsLoginHandler::getSSLPasswdFromGPGFile(const std::string& ssl_id,std::stri
|
|||||||
fclose(sslPassphraseFile);
|
fclose(sslPassphraseFile);
|
||||||
|
|
||||||
std::cerr << "opening sslPassphraseFile : " << getSSLPasswdFileName(ssl_id).c_str() << std::endl;
|
std::cerr << "opening sslPassphraseFile : " << getSSLPasswdFileName(ssl_id).c_str() << std::endl;
|
||||||
|
|
||||||
// gpgme_data_t cipher;
|
|
||||||
// gpgme_data_t plain;
|
|
||||||
// gpgme_data_new (&plain);
|
|
||||||
|
|
||||||
// if( gpgme_data_new_from_stream (&cipher, sslPassphraseFile) != GPG_ERR_NO_ERROR)
|
|
||||||
// {
|
|
||||||
// std::cerr << "Error while creating stream from ssl passwd file." << std::endl ;
|
|
||||||
// return 0 ;
|
|
||||||
// }
|
|
||||||
|
|
||||||
std::string plain ;
|
std::string plain ;
|
||||||
|
|
||||||
if (AuthGPG::getAuthGPG()->decryptTextFromFile(plain,getSSLPasswdFileName(ssl_id)))
|
if (AuthGPG::getAuthGPG()->decryptTextFromFile(plain,getSSLPasswdFileName(ssl_id)))
|
||||||
{
|
{
|
||||||
std::cerr << "Decrypting went ok !" << std::endl;
|
std::cerr << "Decrypting went ok !" << std::endl;
|
||||||
// gpgme_data_write (plain, "", 1);
|
|
||||||
// sslPassword = std::string(gpgme_data_release_and_get_mem(plain, NULL));
|
|
||||||
sslPassword = plain ;
|
sslPassword = plain ;
|
||||||
std::cerr << "sslpassword: " << "********************" << std::endl;
|
std::cerr << "sslpassword: " << "******************** (length = " << sslPassword.length() ")" << std::endl;
|
||||||
// std::cerr << "sslpassword: \"" << sslPassword << "\"" << std::endl;
|
|
||||||
// gpgme_data_release (cipher);
|
|
||||||
// fclose(sslPassphraseFile);
|
|
||||||
|
|
||||||
return true ;
|
return sslPassword.length() > 0 ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// gpgme_data_release (plain);
|
|
||||||
// gpgme_data_release (cipher);
|
|
||||||
// fclose(sslPassphraseFile);
|
|
||||||
sslPassword = "" ;
|
sslPassword = "" ;
|
||||||
std::cerr << "Error : decrypting went wrong !" << std::endl;
|
std::cerr << "Error : decrypting went wrong !" << std::endl;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user