Error::generate_xpgp: Couldn't Create Key Fil

Old SourceForge Discussion forum that is now archived. Please use one of the other forums.

Error::generate_xpgp: Couldn't Create Key Fil

Postby mahendra » Thu Oct 09, 2008 5:06 pm

Hello All,

While calling following API for generating a certificate.

bool RsGenerateCertificate(RsInit * config,std::string name, std::string org, std::string loc, std::string country,std::string passwd, std::string & errString);

in following file/code:

http://retromessenger.svn.sourceforge.net/viewvc/retromessenger/wx/trunk/RetroMessengerCertificateDlg.cpp?view=markup

getting following errors:

generate_xpgp: Couldn't Create Key File! : /home/keys/user_pk.pem

I have checked with retroshare code and it is not generating key

in xPGP_aux.c fiile
// first generate a key....
if ((pkey=EVP_PKEY_new()) == NULL)
{
fprintf(stderr,"generate_xpgp: Couldn't Create Key\n");
return 0;
}

and in p_lic.c it is fail to allocate memory

EVP_PKEY *EVP_PKEY_new(void)
{
EVP_PKEY *ret;

ret=(EVP_PKEY *)OPENSSL_malloc(sizeof(EVP_PKEY));
if (ret == NULL)
{
EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE);
return


Can you please add your suggestions, why it is not allocating memory?

Thanks & Regards,
Mahendra (Retromessenger Team)
mahendra
 

RE: Error::generate_xpgp: Couldn't Create Key

Postby Dr Bob » Mon Oct 13, 2008 11:01 pm

My Guess is that you didn't initialise the OpenSSL libraries properly.

If you look in /libretroshare/src/pqi/ authxpgp.cc : 140

you can see the functions that libretroshare calls. In particular:
SSL_load_error_strings();
SSL_library_init();

or alternatively you can call AuthXPGP::InitAuth(NULL, NULL, NULL);
which will initialise the libraries for you.

DrBob,
Dr Bob
 

RE: Error::generate_xpgp: Couldn't Create Key Fil

Postby mahendra » Tue Oct 14, 2008 9:58 am

Hello DrBob,

Thanks for reply!!

I have tried of calling AuthXPGP::InitAuth(NULL, NULL, NULL);
But it giving errors on including file

i will mention compilation errors(indicates that the library we are using libretroshare.a is improper may be library is not linking properly.....any suggestions??)

libraries/retroshare/pqi/authxpgp.h:55: error: expected `)' before ‘*’ token
libraries/retroshare/pqi/authxpgp.h:74: error: ISO C++ forbids declaration of ‘XPGP’ with no type
libraries/retroshare/pqi/authxpgp.h:74: error: expected ‘;’ before ‘*’ token
libraries/retroshare/pqi/authxpgp.h:136: error: ‘XPGP’ has not been declared
libraries/retroshare/pqi/authxpgp.h:137: error: ‘XPGP’ has not been declared
libraries/retroshare/pqi/authxpgp.h:138: error: ‘XPGP’ has not been declared
libraries/retroshare/pqi/authxpgp.h:147: error: ‘XPGP’ has not been declared
libraries/retroshare/pqi/authxpgp.h:149: error: ISO C++ forbids declaration of ‘XPGP’ with no type
libraries/retroshare/pqi/authxpgp.h:149: error: expected ‘;’ before ‘*’ token
libraries/retroshare/pqi/authxpgp.h:150: error: ISO C++ forbids declaration of ‘XPGP’ with no type
libraries/retroshare/pqi/authxpgp.h:150: error: expected ‘;’ before ‘*’ token
libraries/retroshare/pqi/authxpgp.h:151: error: ‘XPGP’ has not been declared
libraries/retroshare/pqi/authxpgp.h:153: error: ISO C++ forbids declaration of ‘XPGP’ with no type
libraries/retroshare/pqi/authxpgp.h:153: error: expected ‘;’ before ‘*’ token
libraries/retroshare/pqi/authxpgp.h:154: error: ‘XPGP’ has not been declared
libraries/retroshare/pqi/authxpgp.h:168: error: ISO C++ forbids declaration of ‘XPGP_KEYRING’ with no type
libraries/retroshare/pqi/authxpgp.h:168: error: expected ‘;’ before ‘*’ token
libraries/retroshare/pqi/authxpgp.h:189: error: ‘XPGP’ was not declared in this scope
libraries/retroshare/pqi/authxpgp.h:189: error: ‘cert’ was not declared in this scope
libraries/retroshare/pqi/authxpgp.h:190: error: ‘XPGP’ was not declared in this scope
libraries/retroshare/pqi/authxpgp.h:190: error: ‘cert’ was not declared in this scope
libraries/retroshare/pqi/authxpgp.h:191: error: ‘XPGP’ was not declared in this scope
libraries/retroshare/pqi/authxpgp.h:191: error: ‘xpgp’ was not declared in this scope
libraries/retroshare/pqi/authxpgp.h:195: error: ‘XPGP’ was not declared in this scope
libraries/retroshare/pqi/authxpgp.h:195: error: ‘xpgp’ was not declared in this scope
libraries/retroshare/pqi/authxpgp.h:195: error: expected primary-expression before ‘&’ token
libraries/retroshare/pqi/authxpgp.h:195: error: ‘xpgpid’ was not declared in this scope
libraries/retroshare/pqi/authxpgp.h:195: error: initializer expression list treated as compound expression
In file included from libraries/retroshare/pqi/pqipersongrp.h:32,
from libraries/retroshare/rsserver/p3face.h:34,
from RetroMessengerCertificateDlg.cpp:43:
libraries/retroshare/pqi/pqilistener.h:41: warning: unused parameter ‘addr’
In file included from libraries/retroshare/rsserver/p3face.h:34,
from RetroMessengerCertificateDlg.cpp:43:
libraries/retroshare/pqi/pqipersongrp.h:88: warning: unused parameter ‘item’
libraries/retroshare/pqi/pqipersongrp.h:88: warning: unused parameter ‘global’
RetroMessengerCertificateDlg.cpp:56: warning: unused parameter ‘event’
make[1]: *** [.obj/Release/RetroMessengerCertificateDlg.o] Error 1
make: *** [RetroMessenger] Error 2


And at the same time we have fixed the previouse error

generate_xpgp: Couldn't Create Key File! : /home/keys/user_pk.pem
it was due to to improper path, we need to generate private key in working directory/where retromessenger will be installed.
Generating key at /usr/local/key or /home/key can have permission and insecurity issue.

so now private key is getting generate but still create XPGP is failing because can not read the private key:

generate_xpgp() Saved Private Key : ./keys/user_pk.pem
generate_xpgp() Couldn't Read Private Key : ./keys/user_pk.pem

Any suggestions.

Thanks & Kind Regards,
Mahendra (Retromessenger Team)
mahendra
 

RE: Error::generate_xpgp: Couldn't Create Key

Postby Dr Bob » Wed Oct 15, 2008 8:33 pm

Looks like you're missing the headers.
What is your full compile path?


as for the generate_xpgp() issue...

if you look at the code in: openssl-0.9.7g-xpgp-0.1c/crypto/xpgp/xPGP_aux.c : 200

you will see that it successfully opened the file!,
but the call to PEM_read_PrivateKey() failed.

whats in the file? does it look like a normal private key file?

DrBob
Dr Bob
 

RE: Error::generate_xpgp: Couldn't Create Key Fil

Postby mahendra » Thu Oct 16, 2008 10:12 am

Hello DrBob,

Thanks for reply.
My Full compile path is
/home/mahendra/retrosvn/retromessenger/wx/trunk

and library path is as below
/home/mahendra/retrosvn/retromessenger/wx/trunk/libraries/openssl-xpgp

About Generate Certificate.

Yeah RS private key file was as usual.
and now it is generating Certificate file as well
(both the files user_cert.pem and user_pk.pem are getting generated fine)

actually it was due to some logical error on RM-gui code.

and thats why was not able to read (as you mentioned) the file at
xpgp-0.1c/crypto/xpgp/xPGP_aux.c : 200

But now good news is that Both Certificate Generation and Login are working for Retromessneger :)

Again thanks for your suggestions and guidence.

Kind Regards,
Mahendra (Retromessenger Team)
mahendra
 

RE: Error::generate_xpgp: Couldn't Create Key

Postby Dr Bob » Thu Oct 16, 2008 11:51 pm

glad you got it working,

db.
Dr Bob
 

RE: Error::generate_xpgp: Couldn't Create Key Fil

Postby mahendra » Fri Oct 17, 2008 1:34 pm

Hello DrBob,

Here i will correct my sentence about Login working.

Actually login is working at GUI level only.
Still we need to work on that.

We have few questions.
Once certificate is generated and before login we need to authenticate user and certificate and then we need to load certificate and password.

Do we need to make a check on anything else?

and once done with authentication, what all parameters are we suppose to get from retroshare librarty, required to get online(login)

i am listing few which i guess may be

(1)User information (RS config)
(2)All friends informtion (rsid, name etc)
(3)Need to have a UDP socket connection (may be RM-UI need to be connected with Retroshare Server??).

Please add your suggestions.

Thanks & Kind Regards,
Mahendra (Retromessenger Team)
mahendra
 

RE: Error::generate_xpgp: Couldn't Create Key Fil

Postby mahendra » Fri Oct 17, 2008 3:41 pm

Also while logging in what are the network connectivity APIs in library?

About Socket(connect etc)?
mahendra
 

RE: Error::generate_xpgp: Couldn't Create Key

Postby Dr Bob » Fri Oct 17, 2008 6:51 pm

The parameters required to setup libretroshare are specified in RsConfig.

Actually all the APIs to control libretroshare are in libretroshare/src/rsiface/
You shouldn't need to call openssl functions directly....

libretroshare works by having a specific configuration directory.
This ( + password) is the only bit you should have to specify to get libretroshare running.
It will use standard defaults for all other parameters.

The best way to get it all working is to duplicate what is happening in retroshare-nogui....
look in libretroshare/src/rsiface/retroshare.cc
and if you want to see how retroshare-gui starts up...
look in: retroshare-gui/src/main.cpp which is similar but more complex.

Instead of posting a whole lot of code here - I'll write some better comments in
libretroshare/src/rsiface/retroshare.cc, if you check out the latest version from SVN in
a couple of hours - they should be in by then.

DrBob.

NOTES:
(1) libretroshare handles all the networking - you shouldn't have to do anything.
(2) libretroshare handles all your friends lists... the API to control this stuff is in rsiface/rspeers.h
all you need to do is pass it the certificates of new friends to load them in.
Dr Bob
 

RE: Error::generate_xpgp: Couldn't Create Key Fil

Postby mahendra » Fri Oct 17, 2008 7:38 pm

thanks a lot for information.

We will wait for Updated Code in svn.

Regards,
Mahendra (Retromessenger Team)
mahendra
 


Return to Developers Corner - Archive

Who is online

Users browsing this forum: No registered users and 1 guest