diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cli.c | 22 | ||||
-rw-r--r-- | src/serv.c | 8 |
2 files changed, 24 insertions, 6 deletions
@@ -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); |