From 0332c910b60f4d652f87cb3f54f669f241a44446 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kou=C5=99il?= Date: Fri, 13 Jan 2012 14:32:35 +0000 Subject: [PATCH] canl_ctx_set_ssl_cred() added to public API - removed the previous attempts --- emi.canl.canl-c/src/canl.c | 2 ++ emi.canl.canl-c/src/canl.h | 6 ++++++ emi.canl.canl-c/src/canl_cert.c | 2 ++ emi.canl.canl-c/src/canl_locl.h | 5 ----- emi.canl.canl-c/src/canl_sample_server.c | 3 +-- emi.canl.canl-c/src/canl_ssl.c | 7 +++++++ 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/emi.canl.canl-c/src/canl.c b/emi.canl.canl-c/src/canl.c index 10179e0..e831b32 100644 --- a/emi.canl.canl-c/src/canl.c +++ b/emi.canl.canl-c/src/canl.c @@ -370,6 +370,7 @@ size_t canl_io_write(canl_ctx cc, canl_io_handler io, void *buffer, size_t size, return b_written; } +#if 0 int canl_set_ctx_own_cert(canl_ctx cc, canl_x509 cert, canl_stack_of_x509 chain, canl_pkey key) { @@ -409,3 +410,4 @@ int canl_set_ctx_own_cert_file(canl_ctx cc, char *cert, char *key, } return err; } +#endif diff --git a/emi.canl.canl-c/src/canl.h b/emi.canl.canl-c/src/canl.h index ba2b34d..0e0f82f 100644 --- a/emi.canl.canl-c/src/canl.h +++ b/emi.canl.canl-c/src/canl.h @@ -20,6 +20,8 @@ typedef void *canl_principal; typedef long canl_err_code; +typedef char (*canl_password_callback)(canl_ctx cc, void *userdata); + canl_ctx CANL_CALLCONV canl_create_ctx(); @@ -72,6 +74,10 @@ canl_mech2str(canl_ctx, gss_OID); const gss_OID CANL_CALLCONV canl_str2mech(canl_ctx, const char mech); +canl_err_code CANL_CALLCONV +canl_ctx_set_ssl_cred(canl_ctx cc, char *cert, char *key, + canl_password_callback cb, void *userdata); + #ifdef __cplusplus } #endif diff --git a/emi.canl.canl-c/src/canl_cert.c b/emi.canl.canl-c/src/canl_cert.c index 6069eb2..2d834e1 100644 --- a/emi.canl.canl-c/src/canl_cert.c +++ b/emi.canl.canl-c/src/canl_cert.c @@ -4,6 +4,7 @@ static int set_cert(glb_ctx *cc, X509 *cert); static int set_key_file(glb_ctx *cc, char *key); static int set_cert_file(glb_ctx *cc, char *cert); +#if 0 //TODO just stub int do_set_ctx_own_cert(glb_ctx *cc, canl_x509 cert, canl_stack_of_x509 chain, canl_pkey key) @@ -33,6 +34,7 @@ int do_set_ctx_own_cert(glb_ctx *cc, canl_x509 cert, canl_stack_of_x509 chain, */ return 0; } +#endif static int set_cert(glb_ctx *cc, X509 *cert) { diff --git a/emi.canl.canl-c/src/canl_locl.h b/emi.canl.canl-c/src/canl_locl.h index 951fe1e..c540a6b 100644 --- a/emi.canl.canl-c/src/canl_locl.h +++ b/emi.canl.canl-c/src/canl_locl.h @@ -31,8 +31,6 @@ #include "canl.h" -#include "canl_ssl.h" - typedef struct canl_err_desc { CANL_ERROR code; const char *desc; @@ -110,7 +108,4 @@ int ssl_write(glb_ctx *cc, io_handler *io, void *buffer, size_t size, struct timeval *tout); int ssl_close(glb_ctx *cc, io_handler *io); -int do_set_ctx_own_cert(glb_ctx *cc, canl_x509 cert, canl_stack_of_x509 chain, - canl_pkey key); -int do_set_ctx_own_cert_file(glb_ctx *cc, char *cert, char *key); #endif diff --git a/emi.canl.canl-c/src/canl_sample_server.c b/emi.canl.canl-c/src/canl_sample_server.c index 9814106..800e0ab 100644 --- a/emi.canl.canl-c/src/canl_sample_server.c +++ b/emi.canl.canl-c/src/canl_sample_server.c @@ -58,8 +58,7 @@ int main(int argc, char *argv[]) } if (serv_cert || serv_key){ - err = canl_set_ctx_own_cert_file(my_ctx, serv_cert, serv_key, - NULL, NULL); + err = canl_ctx_set_ssl_cred(my_ctx, serv_cert, serv_key, NULL, NULL); if (err) { printf("[SERVER] cannot set certificate or key to context: %s\n", canl_get_error_message(my_ctx)); diff --git a/emi.canl.canl-c/src/canl_ssl.c b/emi.canl.canl-c/src/canl_ssl.c index c702b54..21902c6 100644 --- a/emi.canl.canl-c/src/canl_ssl.c +++ b/emi.canl.canl-c/src/canl_ssl.c @@ -714,6 +714,13 @@ int ssl_close(glb_ctx *cc, io_handler *io) } } +canl_err_code +canl_ctx_set_ssl_cred(canl_ctx cc, char *cert, char *key, + canl_password_callback cb, void *userdata) +{ + return ENOSYS; +} + #ifdef DEBUG static void dbg_print_ssl_error(int errorcode) { -- 1.8.2.3