Addition of several utility functions:

(1) xpgp_id to extract the name/id from a certificate.
(2) dht_bootstrap to check the status of the bootstrap peers.

Various bits of code needed to be rearranged to make these utilities possible.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@394 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-03-21 02:02:58 +00:00
parent e1f4dc1dff
commit 7044822e1f
12 changed files with 651 additions and 31 deletions

View file

@ -34,15 +34,18 @@ RSOBJ = $(BASE_OBJ) $(LOOP_OBJ) \
$(GRP_OBJ) \
$(OTHER_OBJ)
TESTOBJ = net_test.o dht_test.o
TESTOBJ = xpgp_id.o net_test.o dht_test.o
#conn_test.o
TESTS = net_test dht_test
TESTS = xpgp_id net_test dht_test
#conn_test
all: librs tests
xpgp_id: xpgp_id.o
$(CC) $(CFLAGS) -o xpgp_id xpgp_id.o $(LIBS)
dht_test: dht_test.o
$(CC) $(CFLAGS) -o dht_test dht_test.o $(LIBS)

View file

@ -1186,7 +1186,7 @@ bool AuthXPGP::ProcessXPGP(XPGP *xpgp, std::string &id)
}
bool AuthXPGP::getXPGPid(XPGP *xpgp, std::string &xpgpid)
bool getXPGPid(XPGP *xpgp, std::string &xpgpid)
{
#ifdef AUTHXPGP_DEBUG
std::cerr << "AuthXPGP::getXPGPid()";
@ -1320,7 +1320,7 @@ int pem_passwd_cb(char *buf, int size, int rwflag, void *password)
// Not dependent on sslroot. load, and detroys the XPGP memory.
int LoadCheckXPGPandGetName(const char *cert_file, std::string &userName)
int LoadCheckXPGPandGetName(const char *cert_file, std::string &userName, std::string &userId)
{
/* This function loads the XPGP certificate from the file,
* and checks the certificate
@ -1352,6 +1352,11 @@ int LoadCheckXPGPandGetName(const char *cert_file, std::string &userName)
userName = getX509CNString(xpgp->subject->subject);
}
if (!getXPGPid(xpgp, userId))
{
valid = false;
}
// clean up.
XPGP_free(xpgp);

View file

@ -144,7 +144,6 @@ bool loadCertificates(bool &oldFormat, std::map<std::string, std::string> &key
/* Helper Functions */
bool getXPGPid(XPGP *xpgp, std::string &xpgpid);
bool ProcessXPGP(XPGP *xpgp, std::string &id);
XPGP * loadXPGPFromPEM(std::string pem);
@ -191,7 +190,9 @@ std::list<std::string> getXPGPsigners(XPGP *cert);
std::string getXPGPInfo(XPGP *cert);
std::string getXPGPAuthCode(XPGP *xpgp);
int LoadCheckXPGPandGetName(const char *cert_file, std::string &userName);
int LoadCheckXPGPandGetName(const char *cert_file,
std::string &userName, std::string &userId);
bool getXPGPid(XPGP *xpgp, std::string &xpgpid);
#endif // MRK_SSL_XPGP_CERT_HEADER

View file

@ -31,8 +31,8 @@
#include "util/rsprint.h"
#define DHT_DEBUG 1
/*****
* #define DHT_DEBUG 1
* #define P3DHTMGR_USE_LOCAL_UDP_CONN 1 // For Testing only
****/

View file

@ -0,0 +1,44 @@
/***** Extract XPGP Id *****/
#include "pqi/authxpgp.h"
#include <iostream>
#include <sstream>
int main(int argc, char **argv)
{
if (argc < 2)
{
std::cerr << "Usage: " << argv[0] << " <certfile>";
std::cerr << std::endl;
exit(1);
}
std::string userName, userId;
if (LoadCheckXPGPandGetName(argv[1], userName, userId))
{
std::cerr << "Cert Ok: name: " << userName;
std::cerr << std::endl;
std::cerr << "id = \"" << userId << "\"";
std::cerr << std::endl;
}
else
{
std::cerr << "Cert Check Failed";
std::cerr << std::endl;
}
}