39db6f6
diff -up openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/lib/wsman-curl-client-transport.c.orig openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/lib/wsman-curl-client-transport.c
39db6f6
--- openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/lib/wsman-curl-client-transport.c.orig	2016-07-27 16:03:55.000000000 +0200
39db6f6
+++ openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/lib/wsman-curl-client-transport.c	2017-01-16 14:40:03.094728843 +0100
39db6f6
@@ -241,12 +241,16 @@ write_handler( void *ptr, size_t size, s
c4e0090
 static int ssl_certificate_thumbprint_verify_callback(X509_STORE_CTX *ctx, void *arg)
c4e0090
 {
c4e0090
 	unsigned char *thumbprint = (unsigned char *)arg;
c4e0090
-	X509 *cert = ctx->cert;
c4e0090
 	EVP_MD                                  *tempDigest;
c4e0090
 
c4e0090
 	unsigned char   tempFingerprint[EVP_MAX_MD_SIZE];
c4e0090
 	unsigned int      tempFingerprintLen;
c4e0090
 	tempDigest = (EVP_MD*)EVP_sha1( );
c4e0090
+
c4e0090
+	X509 *cert = X509_STORE_CTX_get_current_cert(ctx);
c4e0090
+	if(!cert)
c4e0090
+		return 0;
c4e0090
+
c4e0090
 	if ( X509_digest(cert, tempDigest, tempFingerprint, &tempFingerprintLen ) <= 0)
c4e0090
 		return 0;
c4e0090
 	if(!memcmp(tempFingerprint, thumbprint, tempFingerprintLen))
39db6f6
diff -up openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/compat_unix.h.orig openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/compat_unix.h
39db6f6
--- openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/compat_unix.h.orig	2016-07-27 16:03:55.000000000 +0200
39db6f6
+++ openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/compat_unix.h	2017-01-16 14:40:03.094728843 +0100
39db6f6
@@ -27,7 +27,6 @@
39db6f6
 	pthread_create(&tid, NULL, (void *(*)(void *))a, c); } while (0)
39db6f6
 #endif /* !NO_THREADS */
c4e0090
 
39db6f6
-#define	SSL_LIB				"libssl.so"
39db6f6
 #define	DIRSEP				'/'
39db6f6
 #define	IS_DIRSEP_CHAR(c)		((c) == '/')
39db6f6
 #define	O_BINARY			0
39db6f6
diff -up openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/config.h.orig openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/config.h
39db6f6
--- openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/config.h.orig	2017-01-16 14:40:57.223705664 +0100
39db6f6
+++ openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/config.h	2017-01-16 14:38:15.000000000 +0100
39db6f6
@@ -0,0 +1,29 @@
39db6f6
+/*
39db6f6
+ * Copyright (c) 2004-2005 Sergey Lyubka <valenok@gmail.com>
39db6f6
+ * All rights reserved
39db6f6
+ *
39db6f6
+ * "THE BEER-WARE LICENSE" (Revision 42):
39db6f6
+ * Sergey Lyubka wrote this file.  As long as you retain this notice you
39db6f6
+ * can do whatever you want with this stuff. If we meet some day, and you think
39db6f6
+ * this stuff is worth it, you can buy me a beer in return.
39db6f6
+ */
39db6f6
+
39db6f6
+#ifndef CONFIG_HEADER_DEFINED
39db6f6
+#define	CONFIG_HEADER_DEFINED
39db6f6
+
39db6f6
+#define	SHTTPD_VERSION	"1.42"		/* Version			*/
39db6f6
+#define	CONFIG_FILE	"shttpd.conf"	/* Configuration file		*/
39db6f6
+#define	HTPASSWD	".htpasswd"	/* Passwords file name		*/
39db6f6
+#define	URI_MAX		16384		/* Default max request size	*/
39db6f6
+#define	LISTENING_PORTS	"80"		/* Default listening ports	*/
39db6f6
+#define	INDEX_FILES	"index.html,index.htm,index.php,index.cgi"
39db6f6
+#define	CGI_EXT		"cgi,pl,php"	/* Default CGI extensions	*/
39db6f6
+#define	SSI_EXT		"shtml,shtm"	/* Default SSI extensions	*/
39db6f6
+#define	REALM		"mydomain.com"	/* Default authentication realm	*/
39db6f6
+#define	DELIM_CHARS	","		/* Separators for lists		*/
39db6f6
+#define	EXPIRE_TIME	3600		/* Expiration time, seconds	*/
39db6f6
+#define	ENV_MAX		4096		/* Size of environment block	*/
39db6f6
+#define	CGI_ENV_VARS	64		/* Maximum vars passed to CGI	*/
39db6f6
+#define	SERVICE_NAME	"SHTTPD " VERSION	/* NT service name	*/
39db6f6
+
39db6f6
+#endif /* CONFIG_HEADER_DEFINED */
39db6f6
diff -up openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/io_ssl.c.orig openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/io_ssl.c
39db6f6
--- openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/io_ssl.c.orig	2016-07-27 16:03:55.000000000 +0200
39db6f6
+++ openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/io_ssl.c	2017-01-16 14:40:03.094728843 +0100
39db6f6
@@ -11,23 +11,6 @@
39db6f6
 #include "defs.h"
c4e0090
 
c4e0090
 #if !defined(NO_SSL)
c4e0090
-struct ssl_func	ssl_sw[] = {
c4e0090
-	{"SSL_free",			{0}},
c4e0090
-	{"SSL_accept",			{0}},
c4e0090
-	{"SSL_connect",			{0}},
c4e0090
-	{"SSL_read",			{0}},
c4e0090
-	{"SSL_write",			{0}},
c4e0090
-	{"SSL_get_error",		{0}},
c4e0090
-	{"SSL_set_fd",			{0}},
c4e0090
-	{"SSL_new",			{0}},
c4e0090
-	{"SSL_CTX_new",			{0}},
c4e0090
-	{"SSLv23_server_method",	{0}},
c4e0090
-	{"SSL_library_init",		{0}},
c4e0090
-	{"SSL_CTX_use_PrivateKey_file",	{0}},
c4e0090
-	{"SSL_CTX_use_certificate_file",{0}},
c4e0090
-	{NULL,				{0}}
c4e0090
-};
39db6f6
-
c4e0090
 void
39db6f6
 _shttpd_ssl_handshake(struct stream *stream)
39db6f6
 {
39db6f6
diff -up openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/shttpd.c.orig openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/shttpd.c
39db6f6
--- openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/shttpd.c.orig	2016-07-27 16:03:55.000000000 +0200
39db6f6
+++ openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/shttpd.c	2017-01-16 14:40:03.095728843 +0100
39db6f6
@@ -1474,20 +1474,14 @@ set_ssl(struct shttpd_ctx *ctx, const ch
39db6f6
 	char *ssl_disabled_protocols = wsmand_options_get_ssl_disabled_protocols();
39db6f6
 	int		retval = FALSE;
39db6f6
 
39db6f6
-	/* Load SSL library dynamically */
39db6f6
-	if ((lib = dlopen(SSL_LIB, RTLD_LAZY)) == NULL) {
39db6f6
-		_shttpd_elog(E_LOG, NULL, "set_ssl: cannot load %s", SSL_LIB);
39db6f6
-		return (FALSE);
39db6f6
-	}
39db6f6
-
39db6f6
-	for (fp = ssl_sw; fp->name != NULL; fp++)
39db6f6
-		if ((fp->ptr.v_void = dlsym(lib, fp->name)) == NULL) {
39db6f6
-			_shttpd_elog(E_LOG, NULL,"set_ssl: cannot find %s", fp->name);
39db6f6
-			return (FALSE);
39db6f6
-		}
39db6f6
-
39db6f6
 	/* Initialize SSL crap */
39db6f6
+	debug("Initialize SSL");
39db6f6
+	SSL_load_error_strings();
39db6f6
+	#if OPENSSL_VERSION_NUMBER < 0x10100000L
39db6f6
 	SSL_library_init();
39db6f6
+	#else
39db6f6
+	OPENSSL_init_ssl(0, NULL);
39db6f6
+	#endif
39db6f6
 
39db6f6
 	if ((CTX = SSL_CTX_new(SSLv23_server_method())) == NULL)
39db6f6
 		_shttpd_elog(E_LOG, NULL, "SSL_CTX_new error");
39db6f6
@@ -1523,7 +1517,7 @@ set_ssl(struct shttpd_ctx *ctx, const ch
39db6f6
 			if (strncasecmp(protocols[idx].name, ssl_disabled_protocols, blank_ptr-ssl_disabled_protocols) == 0) {
39db6f6
 				//_shttpd_elog(E_LOG, NULL, "SSL: disable %s protocol", protocols[idx].name);
39db6f6
 				debug("SSL: disable %s protocol", protocols[idx].name);
39db6f6
-				SSL_CTX_ctrl(CTX, SSL_CTRL_OPTIONS, protocols[idx].opt, NULL);
39db6f6
+				SSL_CTX_set_options(CTX, protocols[idx].opt);
39db6f6
 				break;
39db6f6
 			}
39db6f6
 		}
39db6f6
diff -up openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/ssl.h.orig openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/ssl.h
39db6f6
--- openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/ssl.h.orig	2016-07-27 16:03:55.000000000 +0200
39db6f6
+++ openwsman-4391e5c68d99c6239e1672d1c8a5a16d7d8c4c2b/src/server/shttpd/ssl.h	2017-01-16 14:40:03.095728843 +0100
39db6f6
@@ -12,50 +12,4 @@
c4e0090
 
39db6f6
 #include <openssl/ssl.h>
c4e0090
 
c4e0090
-#else
c4e0090
-
c4e0090
-/*
c4e0090
- * Snatched from OpenSSL includes. I put the prototypes here to be independent
c4e0090
- * from the OpenSSL source installation. Having this, shttpd + SSL can be
c4e0090
- * built on any system with binary SSL libraries installed.
c4e0090
- */
c4e0090
-
c4e0090
-typedef struct ssl_st SSL;
c4e0090
-typedef struct ssl_method_st SSL_METHOD;
c4e0090
-typedef struct ssl_ctx_st SSL_CTX;
c4e0090
-
c4e0090
-#define	SSL_ERROR_WANT_READ	2
c4e0090
-#define	SSL_ERROR_WANT_WRITE	3
39db6f6
-#define	SSL_ERROR_SYSCALL	5
39db6f6
-#define	SSL_FILETYPE_PEM	1
c4e0090
-
c4e0090
 #endif
c4e0090
-
c4e0090
-/*
c4e0090
- * Dynamically loaded SSL functionality
c4e0090
- */
c4e0090
-struct ssl_func {
c4e0090
-	const char	*name;		/* SSL function name	*/
c4e0090
-	union variant	ptr;		/* Function pointer	*/
c4e0090
-};
c4e0090
-
c4e0090
-extern struct ssl_func	ssl_sw[];
c4e0090
-
c4e0090
-#define	FUNC(x)	ssl_sw[x].ptr.v_func
c4e0090
-
c4e0090
-#define	SSL_free(x)	(* (void (*)(SSL *)) FUNC(0))(x)
c4e0090
-#define	SSL_accept(x)	(* (int (*)(SSL *)) FUNC(1))(x)
c4e0090
-#define	SSL_connect(x)	(* (int (*)(SSL *)) FUNC(2))(x)
c4e0090
-#define	SSL_read(x,y,z)	(* (int (*)(SSL *, void *, int)) FUNC(3))((x),(y),(z))
c4e0090
-#define	SSL_write(x,y,z) \
c4e0090
-	(* (int (*)(SSL *, const void *,int)) FUNC(4))((x), (y), (z))
c4e0090
-#define	SSL_get_error(x,y)(* (int (*)(SSL *, int)) FUNC(5))((x), (y))
c4e0090
-#define	SSL_set_fd(x,y)	(* (int (*)(SSL *, int)) FUNC(6))((x), (y))
c4e0090
-#define	SSL_new(x)	(* (SSL * (*)(SSL_CTX *)) FUNC(7))(x)
c4e0090
-#define	SSL_CTX_new(x)	(* (SSL_CTX * (*)(SSL_METHOD *)) FUNC(8))(x)
c4e0090
-#define	SSLv23_server_method()	(* (SSL_METHOD * (*)(void)) FUNC(9))()
c4e0090
-#define	SSL_library_init() (* (int (*)(void)) FUNC(10))()
c4e0090
-#define	SSL_CTX_use_PrivateKey_file(x,y,z)	(* (int (*)(SSL_CTX *, \
c4e0090
-		const char *, int)) FUNC(11))((x), (y), (z))
c4e0090
-#define	SSL_CTX_use_certificate_file(x,y,z)	(* (int (*)(SSL_CTX *, \
c4e0090
-		const char *, int)) FUNC(12))((x), (y), (z))