Fixed default data rates to sensible options: 200 kB/s down, 50 kB/s up.

Added StoreAllKeys() call after adding new GPG Certificate.
Added Check for successful Req creation (was crashing with NULL pointer).
Switched std::vector.data => &(std::vector[0]) to remove linuxism in radix64.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4851 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-01-27 13:03:59 +00:00
parent e6816c9d6f
commit 00ff694e10
4 changed files with 44 additions and 30 deletions

View File

@ -1117,33 +1117,37 @@ bool AuthGPGimpl::active()
return ((gpgmeInit) && (gpgmeKeySelected));
}
bool AuthGPGimpl::GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &/*errString*/) {
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
gpgme_key_t newKey;
gpgme_genkey_result_t result;
gpg_error_t ERR;
cleanupZombies(2); // cleanup zombies under OSX. (Called before gpgme operation)
if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_genkey(CTX, setKeyPairParams(true, 2048, name, "generated by Retroshare", email, \
passwd).c_str(), NULL, NULL))) {
std::cerr << "Error generating the key" << std::endl;
std::cerr << ProcessPGPmeError(ERR) << std::endl;
return 0;
}
if((result = gpgme_op_genkey_result(CTX)) == NULL)
return 0;
if(GPG_ERR_NO_ERROR != (ERR = gpgme_get_key(CTX, result->fpr, &newKey, 1))) {
std::cerr << "Error reading own key" << std::endl;
return 0;
}
pgpId = newKey->subkeys->keyid;
bool AuthGPGimpl::GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &/*errString*/)
{
{
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
gpgme_key_t newKey;
gpgme_genkey_result_t result;
gpg_error_t ERR;
cleanupZombies(2); // cleanup zombies under OSX. (Called before gpgme operation)
if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_genkey(CTX, setKeyPairParams(true, 2048, name, "generated by Retroshare", email, \
passwd).c_str(), NULL, NULL))) {
std::cerr << "Error generating the key" << std::endl;
std::cerr << ProcessPGPmeError(ERR) << std::endl;
return 0;
}
if((result = gpgme_op_genkey_result(CTX)) == NULL)
return 0;
if(GPG_ERR_NO_ERROR != (ERR = gpgme_get_key(CTX, result->fpr, &newKey, 1))) {
std::cerr << "Error reading own key" << std::endl;
return 0;
}
pgpId = newKey->subkeys->keyid;
}
// reload keys - so yours is now there.
storeAllKeys();
return true;
}

View File

@ -46,6 +46,9 @@ static std::list<std::string> waitingIds;
****/
//#define PGRP_DEBUG 1
#define DEFAULT_DOWNLOAD_KB_RATE (200.0)
#define DEFAULT_UPLOAD_KB_RATE (50.0)
/* MUTEX NOTES:
* Functions like GetRsRawItem() lock itself (pqihandler) and
* likewise ServiceServer and ConfigMgr mutex themselves.
@ -265,8 +268,9 @@ int pqipersongrp::load_config()
pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone,
"pqipersongrp::load_config() Loading Default Rates!");
setMaxRate(true, 500.0);
setMaxRate(false, 500.0);
setMaxRate(true, DEFAULT_DOWNLOAD_KB_RATE);
setMaxRate(false, DEFAULT_UPLOAD_KB_RATE);
}
return 1;

View File

@ -1284,6 +1284,12 @@ bool RsInit::GenerateSSLCertificate(const std::string& gpg_id, const std::st
country.c_str(),
nbits, errString);
if (req == NULL)
{
fprintf(stderr,"RsGenerateCert() Couldn't create Request. Reason: %s\n", errString.c_str());
return false;
}
long days = 3000;
X509 *x509 = AuthSSL::getAuthSSL()->SignX509ReqWithGPG(req, days);

View File

@ -97,7 +97,7 @@ again:
len = buf.size() ;
out = new char[len] ;
memcpy(out,buf.data(),len) ;
memcpy(out,&buf[0],len) ;
}
/****************