ustream-ssl: add support for using a fd instead of ustream as backing
[project/ustream-ssl.git] / ustream-openssl.h
index 20c502d3fb35f2cb2f8f96a961404f9cba9372f9..847f5aa64bff547e2bca19d04b35e7c544904c40 100644 (file)
 #ifndef __USTREAM_OPENSSL_H
 #define __USTREAM_OPENSSL_H
 
+#if defined(HAVE_WOLFSSL)
+#include <wolfssl/options.h>
+#include <wolfssl/openssl/ssl.h>
+#else
 #include <openssl/ssl.h>
 #include <openssl/err.h>
+#endif
+
 #include <stdbool.h>
 
-static inline void *__ustream_ssl_session_new(void *ctx)
-{
-       return SSL_new(ctx);
-}
+struct ustream_ssl_ctx {
+       SSL_CTX *ssl;
+       BIO *debug_bio;
+       ustream_ssl_debug_cb debug_cb;
+       void *debug_cb_priv;
+};
 
-static inline void __ustream_ssl_session_free(void *ssl)
+struct bio_ctx {
+       BIO_METHOD *meth;
+       struct ustream *stream;
+};
+
+static inline void *__ustream_ssl_session_new(struct ustream_ssl_ctx *ctx)
 {
-       SSL_shutdown(ssl);
-       SSL_free(ssl);
+       return SSL_new(ctx->ssl);
 }
 
 static inline char *__ustream_ssl_strerror(int error, char *buffer, int len)
@@ -43,4 +55,9 @@ static inline void __ustream_ssl_update_peer_cn(struct ustream_ssl *us)
 {
 }
 
+static inline void __ustream_ssl_set_server_name(struct ustream_ssl *us)
+{
+       SSL_set_tlsext_host_name(us->ssl, us->server_name);
+}
+
 #endif