summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2002-03-29 11:16:02 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2002-03-29 11:16:02 +0000
commit7a4b822da5cfa5326199b862793d45a2f6141000 (patch)
treeb57d3ee5f6e4641d277734c57b139b3e30b2396f /src
parent6ea230526a69dcb83ff1879b6390227f1e56ff80 (diff)
downloadgnutls-7a4b822da5cfa5326199b862793d45a2f6141000.tar.gz
Some cleanups in the certificate authentication. Parameters are
passed together with the length, to avoid abuse.
Diffstat (limited to 'src')
-rw-r--r--src/cli.c19
-rw-r--r--src/serv-gaa.c107
-rw-r--r--src/serv-gaa.h46
-rw-r--r--src/serv.gaa1
4 files changed, 94 insertions, 79 deletions
diff --git a/src/cli.c b/src/cli.c
index 4afa2d43e6..268bb5e17e 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -161,13 +161,6 @@ int main(int argc, char **argv)
exit(1);
}
- printf("Resolving '%s'...\n", hostname);
- /* get server name */
- server_host = gethostbyname(hostname);
- if (server_host == NULL) {
- fprintf(stderr, "Cannot resolve %s\n", hostname);
- exit(1);
- }
/* X509 stuff */
if (gnutls_certificate_allocate_sc(&xcred) < 0) { /* space for 2 certificates */
@@ -181,6 +174,8 @@ int main(int argc, char **argv)
x509_crlfile, x509ctype);
if (ret < 0) {
fprintf(stderr, "Error setting the x509 trust file\n");
+ } else {
+ printf("Processed %d CA certificate(s).\n", ret);
}
}
@@ -232,6 +227,14 @@ int main(int argc, char **argv)
exit(1);
}
+ printf("Resolving '%s'...\n", hostname);
+ /* get server name */
+ server_host = gethostbyname(hostname);
+ if (server_host == NULL) {
+ fprintf(stderr, "Cannot resolve %s\n", hostname);
+ exit(1);
+ }
+
sd = socket(AF_INET, SOCK_STREAM, 0);
ERR(sd, "socket");
@@ -526,7 +529,7 @@ void gaa_parser(int argc, char **argv)
#else
srp_username = info.srp_username;
srp_passwd = info.srp_passwd;
- x509_cafile = info.x509_certfile;
+ x509_cafile = info.x509_cafile;
x509_keyfile = info.x509_keyfile;
x509_certfile = info.x509_certfile;
pgp_keyfile = info.pgp_keyfile;
diff --git a/src/serv-gaa.c b/src/serv-gaa.c
index 6b60c4ab89..40a24122fd 100644
--- a/src/serv-gaa.c
+++ b/src/serv-gaa.c
@@ -1,7 +1,7 @@
/* File generated by GAA 1.6.0
*/
#define GAA_NO_WIN32
-#line 83 "serv.gaa"
+#line 84 "serv.gaa"
#include <common.h>
#include <stdio.h>
@@ -112,6 +112,7 @@ void gaa_help(void)
__gaa_helpsingle('g', "generate", "", "Generate Diffie Hellman Parameters.");
__gaa_helpsingle('p', "port", """integer"" ", "The port to connect to.");
__gaa_helpsingle(0, "http", "", "Act as an HTTP Server.");
+ __gaa_helpsingle(0, "echo", "", "Act as an Echo Server.");
__gaa_helpsingle(0, "x509fmtder", "", "Use DER format for certificates");
__gaa_helpsingle(0, "x509cafile", """FILE"" ", "Certificate file to use.");
__gaa_helpsingle(0, "pgpkeyring", """FILE"" ", "PGP Key ring file to use.");
@@ -145,51 +146,51 @@ typedef struct _gaainfo gaainfo;
struct _gaainfo
{
-#line 67 "serv.gaa"
+#line 68 "serv.gaa"
char **ctype;
-#line 66 "serv.gaa"
+#line 67 "serv.gaa"
int nctype;
-#line 63 "serv.gaa"
+#line 64 "serv.gaa"
char **kx;
-#line 62 "serv.gaa"
+#line 63 "serv.gaa"
int nkx;
-#line 59 "serv.gaa"
+#line 60 "serv.gaa"
char **macs;
-#line 58 "serv.gaa"
+#line 59 "serv.gaa"
int nmacs;
-#line 55 "serv.gaa"
+#line 56 "serv.gaa"
char **comp;
-#line 54 "serv.gaa"
+#line 55 "serv.gaa"
int ncomp;
-#line 51 "serv.gaa"
+#line 52 "serv.gaa"
char **proto;
-#line 50 "serv.gaa"
+#line 51 "serv.gaa"
int nproto;
-#line 47 "serv.gaa"
+#line 48 "serv.gaa"
char **ciphers;
-#line 46 "serv.gaa"
+#line 47 "serv.gaa"
int nciphers;
-#line 42 "serv.gaa"
+#line 43 "serv.gaa"
char *srp_passwd_conf;
-#line 39 "serv.gaa"
+#line 40 "serv.gaa"
char *srp_passwd;
-#line 36 "serv.gaa"
+#line 37 "serv.gaa"
char *pgp_keyserver;
-#line 33 "serv.gaa"
+#line 34 "serv.gaa"
char *x509_certfile;
-#line 30 "serv.gaa"
+#line 31 "serv.gaa"
char *x509_keyfile;
-#line 27 "serv.gaa"
+#line 28 "serv.gaa"
char *pgp_certfile;
-#line 24 "serv.gaa"
+#line 25 "serv.gaa"
char *pgp_keyfile;
-#line 21 "serv.gaa"
+#line 22 "serv.gaa"
char *pgp_trustdb;
-#line 18 "serv.gaa"
+#line 19 "serv.gaa"
char *pgp_keyring;
-#line 15 "serv.gaa"
+#line 16 "serv.gaa"
char *x509_cafile;
-#line 12 "serv.gaa"
+#line 13 "serv.gaa"
int fmtder;
#line 9 "serv.gaa"
int http;
@@ -251,7 +252,7 @@ int gaa_error = 0;
#define GAA_MULTIPLE_OPTION 3
#define GAA_REST 0
-#define GAA_NB_OPTION 22
+#define GAA_NB_OPTION 23
#define GAAOPTID_help 1
#define GAAOPTID_list 2
#define GAAOPTID_ctypes 3
@@ -271,9 +272,10 @@ int gaa_error = 0;
#define GAAOPTID_pgpkeyring 17
#define GAAOPTID_x509cafile 18
#define GAAOPTID_x509fmtder 19
-#define GAAOPTID_http 20
-#define GAAOPTID_port 21
-#define GAAOPTID_generate 22
+#define GAAOPTID_echo 20
+#define GAAOPTID_http 21
+#define GAAOPTID_port 22
+#define GAAOPTID_generate 23
#line 168 "gaa.skel"
@@ -613,6 +615,7 @@ int gaa_get_option_num(char *str, int status)
GAA_CHECK1STR("h", GAAOPTID_help);
GAA_CHECK1STR("l", GAAOPTID_list);
GAA_CHECK1STR("", GAAOPTID_x509fmtder);
+ GAA_CHECK1STR("", GAAOPTID_echo);
GAA_CHECK1STR("", GAAOPTID_http);
GAA_CHECK1STR("g", GAAOPTID_generate);
@@ -638,6 +641,7 @@ int gaa_get_option_num(char *str, int status)
GAA_CHECKSTR("pgpkeyring", GAAOPTID_pgpkeyring);
GAA_CHECKSTR("x509cafile", GAAOPTID_x509cafile);
GAA_CHECKSTR("x509fmtder", GAAOPTID_x509fmtder);
+ GAA_CHECKSTR("echo", GAAOPTID_echo);
GAA_CHECKSTR("http", GAAOPTID_http);
GAA_CHECKSTR("port", GAAOPTID_port);
GAA_CHECKSTR("generate", GAAOPTID_generate);
@@ -692,14 +696,14 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
{
case GAAOPTID_help:
OK = 0;
-#line 72 "serv.gaa"
+#line 73 "serv.gaa"
{ gaa_help(); exit(0); ;};
return GAA_OK;
break;
case GAAOPTID_list:
OK = 0;
-#line 71 "serv.gaa"
+#line 72 "serv.gaa"
{ print_list(); exit(0); ;};
return GAA_OK;
@@ -707,7 +711,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
case GAAOPTID_ctypes:
OK = 0;
GAA_LIST_FILL(GAATMP_ctypes.arg1, gaa_getstr, char*, GAATMP_ctypes.size1);
-#line 68 "serv.gaa"
+#line 69 "serv.gaa"
{ gaaval->ctype = GAATMP_ctypes.arg1; gaaval->nctype = GAATMP_ctypes.size1 ;};
return GAA_OK;
@@ -715,7 +719,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
case GAAOPTID_kx:
OK = 0;
GAA_LIST_FILL(GAATMP_kx.arg1, gaa_getstr, char*, GAATMP_kx.size1);
-#line 64 "serv.gaa"
+#line 65 "serv.gaa"
{ gaaval->kx = GAATMP_kx.arg1; gaaval->nkx = GAATMP_kx.size1 ;};
return GAA_OK;
@@ -723,7 +727,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
case GAAOPTID_macs:
OK = 0;
GAA_LIST_FILL(GAATMP_macs.arg1, gaa_getstr, char*, GAATMP_macs.size1);
-#line 60 "serv.gaa"
+#line 61 "serv.gaa"
{ gaaval->macs = GAATMP_macs.arg1; gaaval->nmacs = GAATMP_macs.size1 ;};
return GAA_OK;
@@ -731,7 +735,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
case GAAOPTID_comp:
OK = 0;
GAA_LIST_FILL(GAATMP_comp.arg1, gaa_getstr, char*, GAATMP_comp.size1);
-#line 56 "serv.gaa"
+#line 57 "serv.gaa"
{ gaaval->comp = GAATMP_comp.arg1; gaaval->ncomp = GAATMP_comp.size1 ;};
return GAA_OK;
@@ -739,7 +743,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
case GAAOPTID_protocols:
OK = 0;
GAA_LIST_FILL(GAATMP_protocols.arg1, gaa_getstr, char*, GAATMP_protocols.size1);
-#line 52 "serv.gaa"
+#line 53 "serv.gaa"
{ gaaval->proto = GAATMP_protocols.arg1; gaaval->nproto = GAATMP_protocols.size1 ;};
return GAA_OK;
@@ -747,7 +751,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
case GAAOPTID_ciphers:
OK = 0;
GAA_LIST_FILL(GAATMP_ciphers.arg1, gaa_getstr, char*, GAATMP_ciphers.size1);
-#line 48 "serv.gaa"
+#line 49 "serv.gaa"
{ gaaval->ciphers = GAATMP_ciphers.arg1; gaaval->nciphers = GAATMP_ciphers.size1 ;};
return GAA_OK;
@@ -757,7 +761,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
GAA_TESTMOREARGS;
GAA_FILL(GAATMP_srppasswdconf.arg1, gaa_getstr, GAATMP_srppasswdconf.size1);
gaa_index++;
-#line 43 "serv.gaa"
+#line 44 "serv.gaa"
{ gaaval->srp_passwd_conf = GAATMP_srppasswdconf.arg1 ;};
return GAA_OK;
@@ -767,7 +771,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
GAA_TESTMOREARGS;
GAA_FILL(GAATMP_srppasswd.arg1, gaa_getstr, GAATMP_srppasswd.size1);
gaa_index++;
-#line 40 "serv.gaa"
+#line 41 "serv.gaa"
{ gaaval->srp_passwd = GAATMP_srppasswd.arg1 ;};
return GAA_OK;
@@ -777,7 +781,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
GAA_TESTMOREARGS;
GAA_FILL(GAATMP_pgpkeyserver.arg1, gaa_getstr, GAATMP_pgpkeyserver.size1);
gaa_index++;
-#line 37 "serv.gaa"
+#line 38 "serv.gaa"
{ gaaval->pgp_keyserver = GAATMP_pgpkeyserver.arg1 ;};
return GAA_OK;
@@ -787,7 +791,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
GAA_TESTMOREARGS;
GAA_FILL(GAATMP_x509certfile.arg1, gaa_getstr, GAATMP_x509certfile.size1);
gaa_index++;
-#line 34 "serv.gaa"
+#line 35 "serv.gaa"
{ gaaval->x509_certfile = GAATMP_x509certfile.arg1 ;};
return GAA_OK;
@@ -797,7 +801,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
GAA_TESTMOREARGS;
GAA_FILL(GAATMP_x509keyfile.arg1, gaa_getstr, GAATMP_x509keyfile.size1);
gaa_index++;
-#line 31 "serv.gaa"
+#line 32 "serv.gaa"
{ gaaval->x509_keyfile = GAATMP_x509keyfile.arg1 ;};
return GAA_OK;
@@ -807,7 +811,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
GAA_TESTMOREARGS;
GAA_FILL(GAATMP_pgpcertfile.arg1, gaa_getstr, GAATMP_pgpcertfile.size1);
gaa_index++;
-#line 28 "serv.gaa"
+#line 29 "serv.gaa"
{ gaaval->pgp_certfile = GAATMP_pgpcertfile.arg1 ;};
return GAA_OK;
@@ -817,7 +821,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
GAA_TESTMOREARGS;
GAA_FILL(GAATMP_pgpkeyfile.arg1, gaa_getstr, GAATMP_pgpkeyfile.size1);
gaa_index++;
-#line 25 "serv.gaa"
+#line 26 "serv.gaa"
{ gaaval->pgp_keyfile = GAATMP_pgpkeyfile.arg1 ;};
return GAA_OK;
@@ -827,7 +831,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
GAA_TESTMOREARGS;
GAA_FILL(GAATMP_pgptrustdb.arg1, gaa_getstr, GAATMP_pgptrustdb.size1);
gaa_index++;
-#line 22 "serv.gaa"
+#line 23 "serv.gaa"
{ gaaval->pgp_keyring = GAATMP_pgptrustdb.arg1 ;};
return GAA_OK;
@@ -837,7 +841,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
GAA_TESTMOREARGS;
GAA_FILL(GAATMP_pgpkeyring.arg1, gaa_getstr, GAATMP_pgpkeyring.size1);
gaa_index++;
-#line 19 "serv.gaa"
+#line 20 "serv.gaa"
{ gaaval->pgp_keyring = GAATMP_pgpkeyring.arg1 ;};
return GAA_OK;
@@ -847,18 +851,25 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
GAA_TESTMOREARGS;
GAA_FILL(GAATMP_x509cafile.arg1, gaa_getstr, GAATMP_x509cafile.size1);
gaa_index++;
-#line 16 "serv.gaa"
+#line 17 "serv.gaa"
{ gaaval->x509_cafile = GAATMP_x509cafile.arg1 ;};
return GAA_OK;
break;
case GAAOPTID_x509fmtder:
OK = 0;
-#line 13 "serv.gaa"
+#line 14 "serv.gaa"
{ gaaval->fmtder = 1 ;};
return GAA_OK;
break;
+ case GAAOPTID_echo:
+ OK = 0;
+#line 11 "serv.gaa"
+{ gaaval->http = 0 ;};
+
+ return GAA_OK;
+ break;
case GAAOPTID_http:
OK = 0;
#line 10 "serv.gaa"
@@ -906,7 +917,7 @@ int gaa(int argc, char **argv, gaainfo *gaaval)
if(inited == 0)
{
-#line 74 "serv.gaa"
+#line 75 "serv.gaa"
{ gaaval->generate=0; gaaval->port=5556; gaaval->http=0; gaaval->ciphers=NULL;
gaaval->kx=NULL; gaaval->comp=NULL; gaaval->macs=NULL; gaaval->ctype=NULL; gaaval->nciphers=0;
gaaval->nkx=0; gaaval->ncomp=0; gaaval->nmacs=0; gaaval->nctype = 0;
diff --git a/src/serv-gaa.h b/src/serv-gaa.h
index 99adbf6bbc..0b5d28fbf3 100644
--- a/src/serv-gaa.h
+++ b/src/serv-gaa.h
@@ -8,51 +8,51 @@ typedef struct _gaainfo gaainfo;
struct _gaainfo
{
-#line 67 "serv.gaa"
+#line 68 "serv.gaa"
char **ctype;
-#line 66 "serv.gaa"
+#line 67 "serv.gaa"
int nctype;
-#line 63 "serv.gaa"
+#line 64 "serv.gaa"
char **kx;
-#line 62 "serv.gaa"
+#line 63 "serv.gaa"
int nkx;
-#line 59 "serv.gaa"
+#line 60 "serv.gaa"
char **macs;
-#line 58 "serv.gaa"
+#line 59 "serv.gaa"
int nmacs;
-#line 55 "serv.gaa"
+#line 56 "serv.gaa"
char **comp;
-#line 54 "serv.gaa"
+#line 55 "serv.gaa"
int ncomp;
-#line 51 "serv.gaa"
+#line 52 "serv.gaa"
char **proto;
-#line 50 "serv.gaa"
+#line 51 "serv.gaa"
int nproto;
-#line 47 "serv.gaa"
+#line 48 "serv.gaa"
char **ciphers;
-#line 46 "serv.gaa"
+#line 47 "serv.gaa"
int nciphers;
-#line 42 "serv.gaa"
+#line 43 "serv.gaa"
char *srp_passwd_conf;
-#line 39 "serv.gaa"
+#line 40 "serv.gaa"
char *srp_passwd;
-#line 36 "serv.gaa"
+#line 37 "serv.gaa"
char *pgp_keyserver;
-#line 33 "serv.gaa"
+#line 34 "serv.gaa"
char *x509_certfile;
-#line 30 "serv.gaa"
+#line 31 "serv.gaa"
char *x509_keyfile;
-#line 27 "serv.gaa"
+#line 28 "serv.gaa"
char *pgp_certfile;
-#line 24 "serv.gaa"
+#line 25 "serv.gaa"
char *pgp_keyfile;
-#line 21 "serv.gaa"
+#line 22 "serv.gaa"
char *pgp_trustdb;
-#line 18 "serv.gaa"
+#line 19 "serv.gaa"
char *pgp_keyring;
-#line 15 "serv.gaa"
+#line 16 "serv.gaa"
char *x509_cafile;
-#line 12 "serv.gaa"
+#line 13 "serv.gaa"
int fmtder;
#line 9 "serv.gaa"
int http;
diff --git a/src/serv.gaa b/src/serv.gaa
index eeb6f2ee6e..adcdb79925 100644
--- a/src/serv.gaa
+++ b/src/serv.gaa
@@ -8,6 +8,7 @@ option (p, port) INT "integer" { $port = $1 } "The port to connect to."
#int http;
option (http) { $http = 1 } "Act as an HTTP Server."
+option (echo) { $http = 0 } "Act as an Echo Server."
#int fmtder;
option (x509fmtder) { $fmtder = 1 } "Use DER format for certificates"