summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2001-07-14 14:34:49 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2001-07-14 14:34:49 +0000
commitace74ccba75a199b06a003d55a3c4cf1ed9a5d73 (patch)
treeaef0163ca7ad91cff6d06dbae9e84cb6e1a4ab22 /src
parent843669dbc7f9bb255fe724ecf006b148e21d8819 (diff)
downloadgnutls-ace74ccba75a199b06a003d55a3c4cf1ed9a5d73.tar.gz
several bug fixes in ASN handling. Fixes/additions
in X509 structures handling.
Diffstat (limited to 'src')
-rw-r--r--src/cli.c22
-rw-r--r--src/serv.c8
2 files changed, 24 insertions, 6 deletions
diff --git a/src/cli.c b/src/cli.c
index db2bcd8e30..701ab3036b 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -37,6 +37,8 @@
#define RESUME
#define MAX(X,Y) (X >= Y ? X : Y);
+#define CAFILE "ca.pem"
+#define CRLFILE NULL
static int print_info( GNUTLS_STATE state) {
char *tmp;
@@ -119,8 +121,21 @@ int main(int argc, char** argv)
fprintf(stderr, "global state initialization error\n");
exit(1);
}
-
- gnutls_allocate_srp_client_sc( &cred);
+
+
+
+ /* X509 stuff */
+ if (gnutls_allocate_x509_client_sc( &xcred, 0) < 0) { /* no priv key */
+ fprintf(stderr, "memory error\n");
+ exit(1);
+ }
+ gnutls_set_x509_client_trust( xcred, CAFILE, CRLFILE);
+
+ /* SRP stuff */
+ if (gnutls_allocate_srp_client_sc( &cred)<0) {
+ fprintf(stderr, "memory error\n");
+ exit(1);
+ }
gnutls_set_srp_client_cred( cred, "test", "test");
sd = socket(AF_INET, SOCK_STREAM, 0);
@@ -144,6 +159,7 @@ int main(int argc, char** argv)
gnutls_set_cred( state, GNUTLS_ANON, NULL);
gnutls_set_cred( state, GNUTLS_SRP, &cred);
+
gnutls_set_cred( state, GNUTLS_X509PKI, &xcred);
gnutls_ext_set_dnsname( state, "hello.server.org");
@@ -293,6 +309,8 @@ int main(int argc, char** argv)
shutdown( sd, SHUT_RDWR); /* no more receptions */
close(sd);
+ gnutls_free_srp_client_sc( cred);
+ gnutls_free_x509_client_sc( xcred);
gnutls_deinit( state);
gnutls_global_deinit();
diff --git a/src/serv.c b/src/serv.c
index 80b6c2fe45..12fb36631c 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -302,16 +302,16 @@ int main(int argc, char **argv)
exit(1);
}
- if (gnutls_allocate_x509_sc(&x509_cred, 1) < 0) {
+ if (gnutls_allocate_x509_server_sc(&x509_cred, 1) < 0) {
exit(1);
}
- if (gnutls_set_x509_key( x509_cred, CERTFILE, KEYFILE) < 0) {
+ if (gnutls_set_x509_server_key( x509_cred, CERTFILE, KEYFILE) < 0) {
fprintf(stderr, "X509 PARSE ERROR\nDid you have key.pem and cert.pem?\n");
exit(1);
}
- if (gnutls_set_x509_trust( x509_cred, CAFILE, CRLFILE) < 0) {
+ if (gnutls_set_x509_server_trust( x509_cred, CAFILE, CRLFILE) < 0) {
fprintf(stderr, "X509 PARSE ERROR\nDid you have ca.pem?\n");
exit(1);
}
@@ -418,7 +418,7 @@ int main(int argc, char **argv)
}
close(listen_sd);
- gnutls_free_x509_sc(x509_cred);
+ gnutls_free_x509_server_sc(x509_cred);
gnutls_free_srp_server_sc(x509_cred);
gnutls_free_anon_server_sc(x509_cred);