Compare commits

..

No commits in common. "f9702cf0ef75ae177ce496d9a43f7156bd483c78" and "ffc11ea8ba1b779c191680fc005eff78c3d02d0c" have entirely different histories.

2 changed files with 15 additions and 3 deletions

2
configure vendored
View file

@ -78,7 +78,7 @@ for arg in $SCRIPT_ARGS; do
;; ;;
--with-mbed) --with-mbed)
TLS_IMPL="TLS_MBEDTLS" TLS_IMPL="TLS_MBEDTLS"
TLS_LIBS="-lmbedtls -lmbedx509 -lmbedcrypto" TLS_LIBS="-lmbedtls"
;; ;;
--disable-tls) --disable-tls)
TLS_IMPL="" TLS_IMPL=""

View file

@ -37,7 +37,6 @@
#include <Log.h> #include <Log.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
/* /*
* #include statements and any implementation structures * #include statements and any implementation structures
@ -57,6 +56,17 @@ typedef struct MbedCookie {
mbedtls_pk_context serverkey; mbedtls_pk_context serverkey;
} MbedCookie; } MbedCookie;
static void my_debug(void *ctx, int level,
const char *file, int line,
const char *str)
{
((void) level);
fprintf((FILE *) ctx, "%s:%04d: %s\n", file, line, str);
fflush((FILE *) ctx);
}
void * void *
TlsInitClient(int fd, const char *serverName) TlsInitClient(int fd, const char *serverName)
{ {
@ -133,6 +143,7 @@ TlsInitClient(int fd, const char *serverName)
mbedtls_ctr_drbg_random, mbedtls_ctr_drbg_random,
&cookie->ctrDrbg &cookie->ctrDrbg
); );
mbedtls_ssl_conf_dbg(&cookie->conf, my_debug, stdout);
if ((err = mbedtls_ssl_setup(&cookie->ssl, &cookie->conf)) != 0) if ((err = mbedtls_ssl_setup(&cookie->ssl, &cookie->conf)) != 0)
{ {
char message[256]; char message[256];
@ -217,7 +228,7 @@ TlsInitServer(int fd, const char *crt, const char *key)
goto error; goto error;
} }
if ((err = mbedtls_pk_parse_keyfile(&cookie->serverkey, key, NULL, mbedtls_entropy_func, &cookie->ctrDrbg)) != 0) if ((err = mbedtls_pk_parse_keyfile(&cookie->serverkey, key, NULL)) != 0)
{ {
char message[256]; char message[256];
mbedtls_strerror(err, message, 255); mbedtls_strerror(err, message, 255);
@ -255,6 +266,7 @@ TlsInitServer(int fd, const char *crt, const char *key)
mbedtls_ctr_drbg_random, mbedtls_ctr_drbg_random,
&cookie->ctrDrbg &cookie->ctrDrbg
); );
mbedtls_ssl_conf_dbg(&cookie->conf, my_debug, stdout);
mbedtls_ssl_conf_ca_chain(&cookie->conf, cookie->cert.next, NULL); mbedtls_ssl_conf_ca_chain(&cookie->conf, cookie->cert.next, NULL);
if ((err = mbedtls_ssl_setup(&cookie->ssl, &cookie->conf)) != 0) if ((err = mbedtls_ssl_setup(&cookie->ssl, &cookie->conf)) != 0)
{ {