X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fustream-ssl.git;a=blobdiff_plain;f=ustream-ssl.h;h=77877885e43103c0e86224e6f6b2a427cf79ef2c;hp=21d89d57e3136d4d1bf40237c7f7750f518b0a49;hb=HEAD;hpb=a77690c5bcbcf9f99882676e8ce6f42dc1fd7c92 diff --git a/ustream-ssl.h b/ustream-ssl.h index 21d89d5..7787788 100644 --- a/ustream-ssl.h +++ b/ustream-ssl.h @@ -19,6 +19,8 @@ #ifndef __USTREAM_SSL_H #define __USTREAM_SSL_H +#include + struct ustream_ssl { struct ustream stream; struct ustream *conn; @@ -26,22 +28,34 @@ struct ustream_ssl { void (*notify_connected)(struct ustream_ssl *us); void (*notify_error)(struct ustream_ssl *us, int error, const char *str); + void (*notify_verify_error)(struct ustream_ssl *us, int error, const char *str); - void *ctx; + struct ustream_ssl_ctx *ctx; void *ssl; + char *peer_cn; + const char *server_name; + int error; bool connected; bool server; + + bool valid_cert; + bool valid_cn; }; +struct ustream_ssl_ctx; + struct ustream_ssl_ops { - void *(*context_new)(bool server); - int (*context_set_crt_file)(void *ctx, const char *file); - int (*context_set_key_file)(void *ctx, const char *file); - void (*context_free)(void *ctx); - int (*init)(struct ustream_ssl *us, struct ustream *conn, void *ctx, bool server); + struct ustream_ssl_ctx *(*context_new)(bool server); + int (*context_set_crt_file)(struct ustream_ssl_ctx *ctx, const char *file); + int (*context_set_key_file)(struct ustream_ssl_ctx *ctx, const char *file); + int (*context_add_ca_crt_file)(struct ustream_ssl_ctx *ctx, const char *file); + void (*context_free)(struct ustream_ssl_ctx *ctx); + + int (*init)(struct ustream_ssl *us, struct ustream *conn, struct ustream_ssl_ctx *ctx, bool server); + int (*set_peer_cn)(struct ustream_ssl *conn, const char *name); }; extern const struct ustream_ssl_ops ustream_ssl_ops; @@ -49,7 +63,9 @@ extern const struct ustream_ssl_ops ustream_ssl_ops; #define ustream_ssl_context_new ustream_ssl_ops.context_new #define ustream_ssl_context_set_crt_file ustream_ssl_ops.context_set_crt_file #define ustream_ssl_context_set_key_file ustream_ssl_ops.context_set_key_file +#define ustream_ssl_context_add_ca_crt_file ustream_ssl_ops.context_add_ca_crt_file #define ustream_ssl_context_free ustream_ssl_ops.context_free #define ustream_ssl_init ustream_ssl_ops.init +#define ustream_ssl_set_peer_cn ustream_ssl_ops.set_peer_cn #endif