X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=ustream-ssl.c;h=2728e00b5b9e0dd82984a058b3ed8b608a001cea;hb=ba34903f4163d0650118bee76f012de961951409;hp=4526db082e4362d1479cb9c7b6e1258ea394ac60;hpb=f19b2ec17f0c3d663a5f349de07b12af40016902;p=project%2Fustream-ssl.git diff --git a/ustream-ssl.c b/ustream-ssl.c index 4526db0..2728e00 100644 --- a/ustream-ssl.c +++ b/ustream-ssl.c @@ -17,6 +17,7 @@ */ #include +#include #include #include "ustream-ssl.h" @@ -41,6 +42,7 @@ static void ustream_ssl_check_conn(struct ustream_ssl *us) us->connected = true; if (us->notify_connected) us->notify_connected(us); + ustream_write_pending(&us->stream); } } @@ -132,11 +134,16 @@ static void ustream_ssl_free(struct ustream *s) uloop_timeout_cancel(&us->error_timer); __ustream_ssl_session_free(us->ssl); + free(us->peer_cn); + us->ctx = NULL; us->ssl = NULL; us->conn = NULL; + us->peer_cn = NULL; us->connected = false; us->error = false; + us->valid_cert = false; + us->valid_cn = false; } static bool ustream_ssl_poll(struct ustream *s) @@ -183,10 +190,20 @@ static int _ustream_ssl_init(struct ustream_ssl *us, struct ustream *conn, struc return 0; } +static int _ustream_ssl_set_peer_cn(struct ustream_ssl *us, const char *name) +{ + us->peer_cn = strdup(name); + __ustream_ssl_update_peer_cn(us); + + return 0; +} + const struct ustream_ssl_ops ustream_ssl_ops = { .context_new = __ustream_ssl_context_new, .context_set_crt_file = __ustream_ssl_set_crt_file, .context_set_key_file = __ustream_ssl_set_key_file, + .context_add_ca_crt_file = __ustream_ssl_add_ca_crt_file, .context_free = __ustream_ssl_context_free, .init = _ustream_ssl_init, + .set_peer_cn = _ustream_ssl_set_peer_cn, };