mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Changed some parameters from "std::string" to "const std::string&" in rsinit.h.
Log the error messages from gpgme (ProcessPGPmeError) to stderr. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4560 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
70d02c718d
commit
43c0594d18
@ -93,7 +93,7 @@ gpgcert::~gpgcert()
|
|||||||
{
|
{
|
||||||
if (key)
|
if (key)
|
||||||
{
|
{
|
||||||
gpgme_key_unref(key);
|
gpgme_key_unref(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -904,8 +904,9 @@ bool AuthGPGimpl::DoOwnSignature(const void *data, unsigned int datalen, void *b
|
|||||||
gpg_error_t ERR;
|
gpg_error_t ERR;
|
||||||
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_sign(CTX,gpgmeData, gpgmeSig, mode)))
|
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_sign(CTX,gpgmeData, gpgmeSig, mode)))
|
||||||
{
|
{
|
||||||
ProcessPGPmeError(ERR);
|
std::cerr << "AuthGPGimpl::Sign FAILED ERR: " << ERR << std::endl;
|
||||||
std::cerr << "AuthGPGimpl::Sign FAILED ERR: " << ERR << std::endl;
|
std::cerr << ProcessPGPmeError(ERR) << std::endl;
|
||||||
|
|
||||||
gpgme_data_release(gpgmeSig);
|
gpgme_data_release(gpgmeSig);
|
||||||
gpgme_data_release(gpgmeData);
|
gpgme_data_release(gpgmeData);
|
||||||
gpgme_signers_clear(CTX);
|
gpgme_signers_clear(CTX);
|
||||||
@ -997,11 +998,11 @@ bool AuthGPGimpl::VerifySignature(const void *data, int datalen, const void *sig
|
|||||||
gpgme_set_armor (CTX, 0);
|
gpgme_set_armor (CTX, 0);
|
||||||
|
|
||||||
gpgme_error_t ERR;
|
gpgme_error_t ERR;
|
||||||
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_verify(CTX,gpgmeSig, gpgmeData, NULL)))
|
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_verify(CTX,gpgmeSig, gpgmeData, NULL)))
|
||||||
{
|
{
|
||||||
ProcessPGPmeError(ERR);
|
std::cerr << "AuthGPGimpl::Verify FAILED" << std::endl;
|
||||||
std::cerr << "AuthGPGimpl::Verify FAILED" << std::endl;
|
std::cerr << ProcessPGPmeError(ERR) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpgme_verify_result_t res = gpgme_op_verify_result(CTX);
|
gpgme_verify_result_t res = gpgme_op_verify_result(CTX);
|
||||||
|
|
||||||
@ -1084,8 +1085,8 @@ bool AuthGPGimpl::GeneratePGPCertificate(std::string name, std::string email,
|
|||||||
|
|
||||||
if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_genkey(CTX, setKeyPairParams(true, 2048, name, "generated by Retroshare", email, \
|
if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_genkey(CTX, setKeyPairParams(true, 2048, name, "generated by Retroshare", email, \
|
||||||
passwd).c_str(), NULL, NULL))) {
|
passwd).c_str(), NULL, NULL))) {
|
||||||
ProcessPGPmeError(ERR);
|
|
||||||
std::cerr << "Error generating the key" << std::endl;
|
std::cerr << "Error generating the key" << std::endl;
|
||||||
|
std::cerr << ProcessPGPmeError(ERR) << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1202,37 +1203,38 @@ bool AuthGPGimpl::getGPGDetails(const std::string &id, RsPeerDetails &d)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPGimpl::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) {
|
bool AuthGPGimpl::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN)
|
||||||
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
{
|
||||||
gpgme_set_armor (CTX, 1);
|
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||||
|
gpgme_set_armor (CTX, 1);
|
||||||
gpg_error_t ERR;
|
gpg_error_t ERR;
|
||||||
|
|
||||||
cleanupZombies(2); // cleanup zombies under OSX. (Called before gpgme operation)
|
cleanupZombies(2); // cleanup zombies under OSX. (Called before gpgme operation)
|
||||||
|
|
||||||
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_decrypt (CTX, CIPHER, PLAIN)))
|
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_decrypt (CTX, CIPHER, PLAIN)))
|
||||||
{
|
{
|
||||||
ProcessPGPmeError(ERR);
|
std::cerr << "AuthGPGimpl::decryptText() Error decrypting text" << std::endl;
|
||||||
std::cerr << "AuthGPGimpl::decryptText() Error decrypting text." << std::endl;
|
std::cerr << ProcessPGPmeError(ERR) << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPGimpl::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) {
|
bool AuthGPGimpl::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER)
|
||||||
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
{
|
||||||
|
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||||
gpgme_encrypt_flags_t* flags = new gpgme_encrypt_flags_t();
|
gpgme_encrypt_flags_t* flags = new gpgme_encrypt_flags_t();
|
||||||
gpgme_key_t keys[2] = {mOwnGpgCert.key, NULL};
|
gpgme_key_t keys[2] = {mOwnGpgCert.key, NULL};
|
||||||
gpgme_set_armor (CTX, 1);
|
gpgme_set_armor (CTX, 1);
|
||||||
gpg_error_t ERR;
|
gpg_error_t ERR;
|
||||||
|
|
||||||
cleanupZombies(2); // cleanup zombies under OSX. (Called before gpgme operation)
|
cleanupZombies(2); // cleanup zombies under OSX. (Called before gpgme operation)
|
||||||
|
|
||||||
|
|
||||||
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_encrypt(CTX, keys, *flags, PLAIN, CIPHER)))
|
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_encrypt(CTX, keys, *flags, PLAIN, CIPHER)))
|
||||||
{
|
{
|
||||||
ProcessPGPmeError(ERR);
|
std::cerr << "AuthGPGimpl::encryptText() Error encrypting text" << std::endl;
|
||||||
std::cerr << "AuthGPGimpl::encryptText() Error encrypting text." << std::endl;
|
std::cerr << ProcessPGPmeError(ERR) << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1415,13 +1417,13 @@ bool AuthGPGimpl::LoadCertificateFromString(const std::string &str, std::string
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
gpgme_data_t gpgmeData;
|
gpgme_data_t gpgmeData;
|
||||||
gpg_error_t ERR ;
|
gpg_error_t ERR ;
|
||||||
|
|
||||||
if (GPG_ERR_NO_ERROR != (ERR = gpgme_data_new_from_mem(&gpgmeData, cleancert.c_str(), cleancert.length(), 1)))
|
if (GPG_ERR_NO_ERROR != (ERR = gpgme_data_new_from_mem(&gpgmeData, cleancert.c_str(), cleancert.length(), 1)))
|
||||||
{
|
{
|
||||||
error_string = ProcessPGPmeError(ERR) ;
|
error_string = ProcessPGPmeError(ERR) ;
|
||||||
std::cerr << "Error create Data" << std::endl;
|
std::cerr << "Error create Data: " << error_string << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* move string data to gpgmeData */
|
/* move string data to gpgmeData */
|
||||||
@ -1869,7 +1871,7 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
|
|||||||
|
|
||||||
|
|
||||||
fprintf(stderr,"keySignCallback Error status\n");
|
fprintf(stderr,"keySignCallback Error status\n");
|
||||||
ProcessPGPmeError(params->err);
|
std::cerr << ProcessPGPmeError(params->err) << std::endl;
|
||||||
|
|
||||||
return params->err;
|
return params->err;
|
||||||
}
|
}
|
||||||
@ -2107,7 +2109,7 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
|
|||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr,"keySignCallback Error status\n");
|
fprintf(stderr,"keySignCallback Error status\n");
|
||||||
ProcessPGPmeError(params->err);
|
std::cerr << ProcessPGPmeError(params->err) << std::endl;
|
||||||
|
|
||||||
return params->err;
|
return params->err;
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,9 @@ class RsInit
|
|||||||
* Account Details (Combined GPG+SSL Setup)
|
* Account Details (Combined GPG+SSL Setup)
|
||||||
*/
|
*/
|
||||||
static bool getPreferedAccountId(std::string &id);
|
static bool getPreferedAccountId(std::string &id);
|
||||||
static bool getPGPEngineFileName(std::string &fileName);
|
static bool getPGPEngineFileName(std::string &fileName);
|
||||||
static bool getAccountIds(std::list<std::string> &ids);
|
static bool getAccountIds(std::list<std::string> &ids);
|
||||||
static bool getAccountDetails(std::string id,
|
static bool getAccountDetails(std::string id, std::string &gpgId, std::string &gpgName, std::string &gpgEmail, std::string &sslName);
|
||||||
std::string &gpgId, std::string &gpgName,
|
|
||||||
std::string &gpgEmail, std::string &sslName);
|
|
||||||
|
|
||||||
static bool ValidateCertificate(std::string &userName) ;
|
static bool ValidateCertificate(std::string &userName) ;
|
||||||
|
|
||||||
@ -85,24 +83,24 @@ class RsInit
|
|||||||
* Generating GPGme Account
|
* Generating GPGme Account
|
||||||
*/
|
*/
|
||||||
static int GetPGPLogins(std::list<std::string> &pgpIds);
|
static int GetPGPLogins(std::list<std::string> &pgpIds);
|
||||||
static int GetPGPLoginDetails(std::string id, std::string &name, std::string &email);
|
static int GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email);
|
||||||
static bool GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString);
|
static bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Login GGP
|
* Login GGP
|
||||||
*/
|
*/
|
||||||
static bool SelectGPGAccount(const std::string& gpgId);
|
static bool SelectGPGAccount(const std::string& gpgId);
|
||||||
static bool LoadGPGPassword(std::string passwd);
|
static bool LoadGPGPassword(const std::string& passwd);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Create SSL Certificates
|
* Create SSL Certificates
|
||||||
*/
|
*/
|
||||||
static bool GenerateSSLCertificate(std::string name, std::string org, std::string loc, std::string country, std::string passwd, std::string &sslId, std::string &errString);
|
static bool GenerateSSLCertificate(const std::string& name, const std::string& org, const std::string& loc, const std::string& country, const std::string& passwd, std::string &sslId, std::string &errString);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* intialises directories for passwords and ssl keys
|
* intialises directories for passwords and ssl keys
|
||||||
*/
|
*/
|
||||||
static bool LoadPassword(std::string id, std::string passwd) ;
|
static bool LoadPassword(const std::string& id, const std::string& passwd) ;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Final Certificate load. This can be called if:
|
* Final Certificate load. This can be called if:
|
||||||
@ -112,8 +110,7 @@ class RsInit
|
|||||||
* This wrapper is used to lock the profile first before
|
* This wrapper is used to lock the profile first before
|
||||||
* finalising the login
|
* finalising the login
|
||||||
*/
|
*/
|
||||||
static int LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath);
|
static int LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath);
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Post Login Options
|
* Post Login Options
|
||||||
@ -140,10 +137,10 @@ class RsInit
|
|||||||
static void setupBaseDir();
|
static void setupBaseDir();
|
||||||
|
|
||||||
/* Account Details */
|
/* Account Details */
|
||||||
static bool get_configinit(std::string dir, std::string &id);
|
static bool get_configinit(const std::string& dir, std::string &id);
|
||||||
static bool create_configinit(std::string dir, std::string id);
|
static bool create_configinit(const std::string& dir, const std::string& id);
|
||||||
|
|
||||||
static bool setupAccount(std::string accountdir);
|
static bool setupAccount(const std::string& accountdir);
|
||||||
|
|
||||||
/* Auto Login */
|
/* Auto Login */
|
||||||
static bool RsStoreAutoLogin() ;
|
static bool RsStoreAutoLogin() ;
|
||||||
@ -158,6 +155,4 @@ class RsInit
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1047,7 +1047,7 @@ int RsInit::GetPGPLogins(std::list<std::string> &pgpIds) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RsInit::GetPGPLoginDetails(std::string id, std::string &name, std::string &email)
|
int RsInit::GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email)
|
||||||
{
|
{
|
||||||
#ifdef GPG_DEBUG
|
#ifdef GPG_DEBUG
|
||||||
std::cerr << "RsInit::GetPGPLoginDetails for \"" << id << "\"" << std::endl;
|
std::cerr << "RsInit::GetPGPLoginDetails for \"" << id << "\"" << std::endl;
|
||||||
@ -1076,7 +1076,7 @@ int RsInit::LockConfigDirectory(const std::string& accountDir, std::string& lock
|
|||||||
{
|
{
|
||||||
const std::string lockFile = accountDir + "/" + "lock";
|
const std::string lockFile = accountDir + "/" + "lock";
|
||||||
|
|
||||||
lockFilePath = lockFile;
|
lockFilePath = lockFile;
|
||||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
#ifndef WINDOWS_SYS
|
#ifndef WINDOWS_SYS
|
||||||
if(RsInitConfig::lockHandle != -1)
|
if(RsInitConfig::lockHandle != -1)
|
||||||
@ -1191,13 +1191,14 @@ bool RsInit::SelectGPGAccount(const std::string& gpgId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RsInit::GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString) {
|
bool RsInit::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString)
|
||||||
return AuthGPG::getAuthGPG()->GeneratePGPCertificate(name, email, passwd, pgpId, errString);
|
{
|
||||||
|
return AuthGPG::getAuthGPG()->GeneratePGPCertificate(name, email, passwd, pgpId, errString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Create SSL Certificates */
|
/* Create SSL Certificates */
|
||||||
bool RsInit::GenerateSSLCertificate(std::string gpg_id, std::string org, std::string loc, std::string country, std::string passwd, std::string &sslId, std::string &errString)
|
bool RsInit::GenerateSSLCertificate(const std::string& gpg_id, const std::string& org, const std::string& loc, const std::string& country, const std::string& passwd, std::string &sslId, std::string &errString)
|
||||||
{
|
{
|
||||||
// generate the private_key / certificate.
|
// generate the private_key / certificate.
|
||||||
// save to file.
|
// save to file.
|
||||||
@ -1213,7 +1214,7 @@ bool RsInit::GenerateSSLCertificate(std::string gpg_id, std::string org, std
|
|||||||
|
|
||||||
int nbits = 2048;
|
int nbits = 2048;
|
||||||
|
|
||||||
std::string name = AuthGPG::getAuthGPG()->getGPGName(gpg_id);
|
std::string name = AuthGPG::getAuthGPG()->getGPGName(gpg_id);
|
||||||
|
|
||||||
// Create the filename .....
|
// Create the filename .....
|
||||||
// Temporary Directory for creating files....
|
// Temporary Directory for creating files....
|
||||||
@ -1248,7 +1249,7 @@ bool RsInit::GenerateSSLCertificate(std::string gpg_id, std::string org, std
|
|||||||
nbits, errString);
|
nbits, errString);
|
||||||
|
|
||||||
long days = 3000;
|
long days = 3000;
|
||||||
X509 *x509 = AuthSSL::getAuthSSL()->SignX509ReqWithGPG(req, days);
|
X509 *x509 = AuthSSL::getAuthSSL()->SignX509ReqWithGPG(req, days);
|
||||||
|
|
||||||
X509_REQ_free(req);
|
X509_REQ_free(req);
|
||||||
if (x509 == NULL) {
|
if (x509 == NULL) {
|
||||||
@ -1262,43 +1263,43 @@ bool RsInit::GenerateSSLCertificate(std::string gpg_id, std::string org, std
|
|||||||
gen_ok = true;
|
gen_ok = true;
|
||||||
|
|
||||||
/* Print the signed Certificate! */
|
/* Print the signed Certificate! */
|
||||||
BIO *bio_out = NULL;
|
BIO *bio_out = NULL;
|
||||||
bio_out = BIO_new(BIO_s_file());
|
bio_out = BIO_new(BIO_s_file());
|
||||||
BIO_set_fp(bio_out,stdout,BIO_NOCLOSE);
|
BIO_set_fp(bio_out,stdout,BIO_NOCLOSE);
|
||||||
|
|
||||||
/* Print it out */
|
/* Print it out */
|
||||||
int nmflag = 0;
|
int nmflag = 0;
|
||||||
int reqflag = 0;
|
int reqflag = 0;
|
||||||
|
|
||||||
X509_print_ex(bio_out, x509, nmflag, reqflag);
|
X509_print_ex(bio_out, x509, nmflag, reqflag);
|
||||||
|
|
||||||
BIO_flush(bio_out);
|
BIO_flush(bio_out);
|
||||||
BIO_free(bio_out);
|
BIO_free(bio_out);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gen_ok = false;
|
gen_ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gen_ok)
|
if (gen_ok)
|
||||||
{
|
{
|
||||||
/* Save cert to file */
|
/* Save cert to file */
|
||||||
// open the file.
|
// open the file.
|
||||||
FILE *out = NULL;
|
FILE *out = NULL;
|
||||||
if (NULL == (out = RsDirUtil::rs_fopen(cert_name.c_str(), "w")))
|
if (NULL == (out = RsDirUtil::rs_fopen(cert_name.c_str(), "w")))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"RsGenerateCert() Couldn't create Cert File");
|
fprintf(stderr,"RsGenerateCert() Couldn't create Cert File");
|
||||||
fprintf(stderr," : %s\n", cert_name.c_str());
|
fprintf(stderr," : %s\n", cert_name.c_str());
|
||||||
gen_ok = false;
|
gen_ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PEM_write_X509(out,x509))
|
if (!PEM_write_X509(out,x509))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"RsGenerateCert() Couldn't Save Cert");
|
fprintf(stderr,"RsGenerateCert() Couldn't Save Cert");
|
||||||
fprintf(stderr," : %s\n", cert_name.c_str());
|
fprintf(stderr," : %s\n", cert_name.c_str());
|
||||||
gen_ok = false;
|
gen_ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(out);
|
fclose(out);
|
||||||
X509_free(x509);
|
X509_free(x509);
|
||||||
@ -1312,14 +1313,14 @@ bool RsInit::GenerateSSLCertificate(std::string gpg_id, std::string org, std
|
|||||||
|
|
||||||
/* try to load it, and get Id */
|
/* try to load it, and get Id */
|
||||||
|
|
||||||
std::string location;
|
std::string location;
|
||||||
std::string gpgid;
|
std::string gpgid;
|
||||||
if (LoadCheckX509(cert_name.c_str(), gpgid, location, sslId) == 0) {
|
if (LoadCheckX509(cert_name.c_str(), gpgid, location, sslId) == 0) {
|
||||||
std::cerr << "RsInit::GenerateSSLCertificate() Cannot check own signature, maybe the files are corrupted." << std::endl;
|
std::cerr << "RsInit::GenerateSSLCertificate() Cannot check own signature, maybe the files are corrupted." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move directory to correct id */
|
/* Move directory to correct id */
|
||||||
std::string finalbase = RsInitConfig::basedir + "/" + sslId + "/";
|
std::string finalbase = RsInitConfig::basedir + "/" + sslId + "/";
|
||||||
/* Rename Directory */
|
/* Rename Directory */
|
||||||
|
|
||||||
@ -1347,7 +1348,7 @@ bool RsInit::GenerateSSLCertificate(std::string gpg_id, std::string org, std
|
|||||||
|
|
||||||
|
|
||||||
/******************* PRIVATE FNS TO HELP with GEN **************/
|
/******************* PRIVATE FNS TO HELP with GEN **************/
|
||||||
bool RsInit::setupAccount(std::string accountdir)
|
bool RsInit::setupAccount(const std::string& accountdir)
|
||||||
{
|
{
|
||||||
/* actual config directory isd */
|
/* actual config directory isd */
|
||||||
|
|
||||||
@ -1407,7 +1408,7 @@ bool RsInit::setupAccount(std::string accountdir)
|
|||||||
|
|
||||||
/***************************** FINAL LOADING OF SETUP *************************/
|
/***************************** FINAL LOADING OF SETUP *************************/
|
||||||
/* Login SSL */
|
/* Login SSL */
|
||||||
bool RsInit::LoadPassword(std::string id, std::string inPwd)
|
bool RsInit::LoadPassword(const std::string& id, const std::string& inPwd)
|
||||||
{
|
{
|
||||||
/* select configDir */
|
/* select configDir */
|
||||||
|
|
||||||
@ -1441,7 +1442,7 @@ bool RsInit::LoadPassword(std::string id, std::string inPwd)
|
|||||||
*/
|
*/
|
||||||
int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath)
|
int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath)
|
||||||
{
|
{
|
||||||
int retVal = LockConfigDirectory(RsInitConfig::configDir, lockFilePath);
|
int retVal = LockConfigDirectory(RsInitConfig::configDir, lockFilePath);
|
||||||
if(retVal != 0)
|
if(retVal != 0)
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|
||||||
@ -1466,7 +1467,6 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath
|
|||||||
*/
|
*/
|
||||||
int RsInit::LoadCertificates(bool autoLoginNT)
|
int RsInit::LoadCertificates(bool autoLoginNT)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (RsInitConfig::load_cert == "")
|
if (RsInitConfig::load_cert == "")
|
||||||
{
|
{
|
||||||
std::cerr << "RetroShare needs a certificate" << std::endl;
|
std::cerr << "RetroShare needs a certificate" << std::endl;
|
||||||
@ -1516,11 +1516,13 @@ int RsInit::LoadCertificates(bool autoLoginNT)
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsInit::RsClearAutoLogin()
|
bool RsInit::RsClearAutoLogin()
|
||||||
{
|
{
|
||||||
return RsLoginHandler::clearAutoLogin(RsInitConfig::preferedId);
|
return RsLoginHandler::clearAutoLogin(RsInitConfig::preferedId);
|
||||||
}
|
}
|
||||||
bool RsInit::get_configinit(std::string dir, std::string &id)
|
|
||||||
|
bool RsInit::get_configinit(const std::string& dir, std::string &id)
|
||||||
{
|
{
|
||||||
// have a config directories.
|
// have a config directories.
|
||||||
|
|
||||||
@ -1551,8 +1553,7 @@ bool RsInit::get_configinit(std::string dir, std::string &id)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RsInit::create_configinit(const std::string& dir, const std::string& id)
|
||||||
bool RsInit::create_configinit(std::string dir, std::string id)
|
|
||||||
{
|
{
|
||||||
// Check for config file.
|
// Check for config file.
|
||||||
std::string initfile = dir + "/";
|
std::string initfile = dir + "/";
|
||||||
|
@ -96,29 +96,6 @@ GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
|
|||||||
newGPGKeyGenUiSetup();
|
newGPGKeyGenUiSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destructor. */
|
|
||||||
//GenCertDialog::~GenCertDialog()
|
|
||||||
//{
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Overloads the default show() slot so we can set opacity*/
|
|
||||||
|
|
||||||
void GenCertDialog::show()
|
|
||||||
{
|
|
||||||
//loadSettings();
|
|
||||||
if(!this->isVisible()) {
|
|
||||||
QWidget::show();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GenCertDialog::closeinfodlg()
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GenCertDialog::newGPGKeyGenUiSetup() {
|
void GenCertDialog::newGPGKeyGenUiSetup() {
|
||||||
|
|
||||||
QString titleStr("<span style=\"font-size:17pt; font-weight:500;"
|
QString titleStr("<span style=\"font-size:17pt; font-weight:500;"
|
||||||
@ -152,9 +129,9 @@ void GenCertDialog::newGPGKeyGenUiSetup() {
|
|||||||
ui.label_3->setText( titleStr.arg( tr("Create a new Location") ) ) ;
|
ui.label_3->setText( titleStr.arg( tr("Create a new Location") ) ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenCertDialog::genPerson()
|
void GenCertDialog::genPerson()
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Check the data from the GUI. */
|
/* Check the data from the GUI. */
|
||||||
std::string genLoc = ui.location_input->text().toUtf8().constData();
|
std::string genLoc = ui.location_input->text().toUtf8().constData();
|
||||||
std::string PGPId;
|
std::string PGPId;
|
||||||
@ -241,12 +218,12 @@ void GenCertDialog::genPerson()
|
|||||||
|
|
||||||
/* Initialise the PGP user first */
|
/* Initialise the PGP user first */
|
||||||
RsInit::SelectGPGAccount(PGPId);
|
RsInit::SelectGPGAccount(PGPId);
|
||||||
//RsInit::LoadGPGPassword(PGPpasswd);
|
//RsInit::LoadGPGPassword(PGPpasswd);
|
||||||
|
|
||||||
std::string sslId;
|
std::string sslId;
|
||||||
std::cerr << "GenCertDialog::genPerson() Generating SSL cert with gpg id : " << PGPId << std::endl;
|
std::cerr << "GenCertDialog::genPerson() Generating SSL cert with gpg id : " << PGPId << std::endl;
|
||||||
std::string err;
|
std::string err;
|
||||||
bool okGen = RsInit::GenerateSSLCertificate(PGPId, "", genLoc, "", sslPasswd, sslId, err);
|
bool okGen = RsInit::GenerateSSLCertificate(PGPId, "", genLoc, "", sslPasswd, sslId, err);
|
||||||
|
|
||||||
if (okGen)
|
if (okGen)
|
||||||
{
|
{
|
||||||
@ -257,20 +234,15 @@ void GenCertDialog::genPerson()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Message Dialog */
|
/* Message Dialog */
|
||||||
QMessageBox::warning ( NULL,
|
QMessageBox::warning( NULL,
|
||||||
"Generate ID Failure",
|
"Generate ID Failure",
|
||||||
"Failed to Generate your new Certificate, maybe PGP password is wrong !",
|
"Failed to Generate your new Certificate, maybe PGP password is wrong !",
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GenCertDialog::selectFriend()
|
void GenCertDialog::selectFriend()
|
||||||
{
|
{
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* still need to find home (first) */
|
/* still need to find home (first) */
|
||||||
|
|
||||||
@ -288,13 +260,10 @@ void GenCertDialog::selectFriend()
|
|||||||
ui.genFriend -> setText("<Invalid Selected>");
|
ui.genFriend -> setText("<Invalid Selected>");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenCertDialog::checkChanged(int /*i*/)
|
void GenCertDialog::checkChanged(int /*i*/)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (i)
|
if (i)
|
||||||
{
|
{
|
||||||
@ -309,14 +278,12 @@ void GenCertDialog::checkChanged(int /*i*/)
|
|||||||
ui.genFriend -> setText("<None Selected>");
|
ui.genFriend -> setText("<None Selected>");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenCertDialog::loadCertificates()
|
void GenCertDialog::loadCertificates()
|
||||||
{
|
{
|
||||||
std::string lockFile;
|
std::string lockFile;
|
||||||
int retVal = RsInit::LockAndLoadCertificates(false, lockFile);
|
int retVal = RsInit::LockAndLoadCertificates(false, lockFile);
|
||||||
switch(retVal)
|
switch(retVal)
|
||||||
{
|
{
|
||||||
case 0: close();
|
case 0: close();
|
||||||
|
@ -38,15 +38,7 @@ public:
|
|||||||
GenCertDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
|
GenCertDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||||
/** Default destructor */
|
/** Default destructor */
|
||||||
|
|
||||||
//~GenCertDialog();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
/** Overloaded QWidget.show */
|
|
||||||
void show();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void closeinfodlg();
|
|
||||||
void genPerson();
|
void genPerson();
|
||||||
//void loadPerson();
|
//void loadPerson();
|
||||||
void selectFriend();
|
void selectFriend();
|
||||||
|
Loading…
Reference in New Issue
Block a user