From 7ff8f023d150dfee71e828908d0634f53d16bda0 Mon Sep 17 00:00:00 2001
From: Andy Green <andy@warmcat.com>
Date: Fri, 27 Apr 2018 08:27:16 +0800
Subject: [PATCH] context info struct: make lws usage all const

---
 lib/context.c                    | 24 ++++++++----------------
 lib/event-libs/libev.c           |  2 +-
 lib/event-libs/libevent.c        |  2 +-
 lib/event-libs/libuv.c           |  2 +-
 lib/libwebsockets.h              |  8 +++-----
 lib/plat/lws-plat-esp32.c        |  4 ++--
 lib/plat/lws-plat-optee.c        |  4 ++--
 lib/plat/lws-plat-unix.c         |  4 ++--
 lib/plat/lws-plat-win.c          |  4 ++--
 lib/private-libwebsockets.h      | 18 +++++++++---------
 lib/roles/h2/ops-h2.c            |  4 ++--
 lib/roles/http/server/server.c   |  8 +++++---
 lib/roles/ws/ext/extension.c     |  2 +-
 lib/roles/ws/ops-ws.c            |  3 ++-
 lib/roles/ws/private.h           |  2 +-
 lib/tls/mbedtls/mbedtls-client.c |  2 +-
 lib/tls/mbedtls/mbedtls-server.c |  2 +-
 lib/tls/mbedtls/ssl.c            |  2 +-
 lib/tls/openssl/openssl-client.c |  2 +-
 lib/tls/openssl/openssl-server.c |  2 +-
 lib/tls/openssl/ssl.c            |  5 +++--
 lib/tls/private.h                | 15 ++++++++-------
 lib/tls/tls-client.c             |  2 +-
 lib/tls/tls-server.c             |  6 +++---
 24 files changed, 62 insertions(+), 67 deletions(-)

diff --git a/lib/context.c b/lib/context.c
index 37f10505..ad79b28d 100644
--- a/lib/context.c
+++ b/lib/context.c
@@ -526,11 +526,12 @@ lws_vhost_destroy2(struct lws_vhost *vh);
 
 LWS_VISIBLE struct lws_vhost *
 lws_create_vhost(struct lws_context *context,
-		 struct lws_context_creation_info *info)
+		 const struct lws_context_creation_info *info)
 {
 	struct lws_vhost *vh = lws_zalloc(sizeof(*vh), "create vhost"),
 			 **vh1 = &context->vhost_list;
 	const struct lws_http_mount *mounts;
+	const struct lws_protocols *pcols = info->protocols;
 	const struct lws_protocol_vhost_options *pvo;
 #ifdef LWS_WITH_PLUGINS
 	struct lws_plugin *plugin = context->plugin_list;
@@ -550,8 +551,8 @@ lws_create_vhost(struct lws_context *context,
 	pthread_mutex_init(&vh->lock, NULL);
 #endif
 
-	if (!info->protocols)
-		info->protocols = &protocols_dummy[0];
+	if (!pcols)
+		pcols = &protocols_dummy[0];
 
 	vh->context = context;
 	if (!info->vhost_name)
@@ -571,7 +572,7 @@ lws_create_vhost(struct lws_context *context,
 #endif
 
 	for (vh->count_protocols = 0;
-	     info->protocols[vh->count_protocols].callback;
+	     pcols[vh->count_protocols].callback;
 	     vh->count_protocols++)
 		;
 
@@ -636,7 +637,7 @@ lws_create_vhost(struct lws_context *context,
 	}
 
 	m = vh->count_protocols;
-	memcpy(lwsp, info->protocols, sizeof(struct lws_protocols) * m);
+	memcpy(lwsp, pcols, sizeof(struct lws_protocols) * m);
 
 	/* for compatibility, all protocols enabled on vhost if only
 	 * the default vhost exists.  Otherwise only vhosts who ask
@@ -676,7 +677,7 @@ lws_create_vhost(struct lws_context *context,
 	    context->options & LWS_SERVER_OPTION_EXPLICIT_VHOSTS)
 		vh->protocols = lwsp;
 	else {
-		vh->protocols = info->protocols;
+		vh->protocols = pcols;
 		lws_free(lwsp);
 	}
 
@@ -942,7 +943,7 @@ lws_destroy_event_pipe(struct lws *wsi)
 }
 
 LWS_VISIBLE struct lws_context *
-lws_create_context(struct lws_context_creation_info *info)
+lws_create_context(const struct lws_context_creation_info *info)
 {
 	struct lws_context *context = NULL;
 	struct lws_plat_file_ops *prev;
@@ -1246,15 +1247,6 @@ lws_create_context(struct lws_context_creation_info *info)
 	if (lws_plat_init(context, info))
 		goto bail;
 
-#if defined(LWS_WITH_HTTP2)
-	/*
-	 * let the user code see what the platform default SETTINGS were, he
-	 * can modify them when he creates the vhosts.
-	 */
-	for (n = 1; n < LWS_H2_SETTINGS_LEN; n++)
-		info->http2_settings[n] = context->set.s[n];
-#endif
-
 	lws_context_init_ssl_library(info);
 
 	context->user_space = info->user;
diff --git a/lib/event-libs/libev.c b/lib/event-libs/libev.c
index d7afc671..6d4efa11 100644
--- a/lib/event-libs/libev.c
+++ b/lib/event-libs/libev.c
@@ -23,7 +23,7 @@
 
 #include "private-libwebsockets.h"
 
-void lws_feature_status_libev(struct lws_context_creation_info *info)
+void lws_feature_status_libev(const struct lws_context_creation_info *info)
 {
 	if (lws_check_opt(info->options, LWS_SERVER_OPTION_LIBEV))
 		lwsl_info("libev support compiled in and enabled\n");
diff --git a/lib/event-libs/libevent.c b/lib/event-libs/libevent.c
index a3c054c7..469a4d86 100644
--- a/lib/event-libs/libevent.c
+++ b/lib/event-libs/libevent.c
@@ -21,7 +21,7 @@
 
 #include "private-libwebsockets.h"
 
-void lws_feature_status_libevent(struct lws_context_creation_info *info)
+void lws_feature_status_libevent(const struct lws_context_creation_info *info)
 {
 	if (lws_check_opt(info->options, LWS_SERVER_OPTION_LIBEVENT))
 		lwsl_info("libevent support compiled in and enabled\n");
diff --git a/lib/event-libs/libuv.c b/lib/event-libs/libuv.c
index 4db5155f..c14d221c 100644
--- a/lib/event-libs/libuv.c
+++ b/lib/event-libs/libuv.c
@@ -22,7 +22,7 @@
 #include "private-libwebsockets.h"
 
 void
-lws_feature_status_libuv(struct lws_context_creation_info *info)
+lws_feature_status_libuv(const struct lws_context_creation_info *info)
 {
 	if (lws_check_opt(info->options, LWS_SERVER_OPTION_LIBUV))
 		lwsl_info("libuv support compiled in and enabled\n");
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index e8bb5d60..35c9692c 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -2949,9 +2949,7 @@ struct lws_context_creation_info {
 	 *	      given here.
 	 */
 	uint32_t	http2_settings[7];
-	/**< CONTEXT: after context creation http2_settings[1] thru [6] have
-	 *	      been set to the lws platform default values.
-	 *   VHOST:   if http2_settings[0] is nonzero, the values given in
+	/**< VHOST:  if http2_settings[0] is nonzero, the values given in
 	 *	      http2_settings[1]..[6] are used instead of the lws
 	 *	      platform default values.
 	 *	      Just leave all at 0 if you don't care.
@@ -3014,7 +3012,7 @@ struct lws_context_creation_info {
  *	one place; they're all handled in the user callback.
  */
 LWS_VISIBLE LWS_EXTERN struct lws_context *
-lws_create_context(struct lws_context_creation_info *info);
+lws_create_context(const struct lws_context_creation_info *info);
 
 /**
  * lws_context_destroy() - Destroy the websocket context
@@ -3117,7 +3115,7 @@ struct lws_vhost;
  */
 LWS_VISIBLE LWS_EXTERN struct lws_vhost *
 lws_create_vhost(struct lws_context *context,
-		 struct lws_context_creation_info *info);
+		 const struct lws_context_creation_info *info);
 
 /**
  * lws_vhost_destroy() - Destroy a vhost (virtual server context)
diff --git a/lib/plat/lws-plat-esp32.c b/lib/plat/lws-plat-esp32.c
index 3ba6ceb8..a46110ce 100644
--- a/lib/plat/lws-plat-esp32.c
+++ b/lib/plat/lws-plat-esp32.c
@@ -335,7 +335,7 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd)
 }
 
 LWS_VISIBLE void
-lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
+lws_plat_drop_app_privileges(const struct lws_context_creation_info *info)
 {
 }
 
@@ -600,7 +600,7 @@ const struct http2_settings const lws_h2_defaults_esp32 = { {
 
 LWS_VISIBLE int
 lws_plat_init(struct lws_context *context,
-	      struct lws_context_creation_info *info)
+	      const struct lws_context_creation_info *info)
 {
 	/* master context has the global fd lookup array */
 	context->lws_lookup = lws_zalloc(sizeof(struct lws *) *
diff --git a/lib/plat/lws-plat-optee.c b/lib/plat/lws-plat-optee.c
index f6354011..5ccbedd6 100644
--- a/lib/plat/lws-plat-optee.c
+++ b/lib/plat/lws-plat-optee.c
@@ -205,7 +205,7 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd)
 }
 
 LWS_VISIBLE void
-lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
+lws_plat_drop_app_privileges(const struct lws_context_creation_info *info)
 {
 }
 
@@ -317,7 +317,7 @@ _lws_plat_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount,
 
 LWS_VISIBLE int
 lws_plat_init(struct lws_context *context,
-	      struct lws_context_creation_info *info)
+	      const struct lws_context_creation_info *info)
 {
 	/* master context has the global fd lookup array */
 	context->lws_lookup = lws_zalloc(sizeof(struct lws *) *
diff --git a/lib/plat/lws-plat-unix.c b/lib/plat/lws-plat-unix.c
index caf4be66..4cbcc7c1 100644
--- a/lib/plat/lws-plat-unix.c
+++ b/lib/plat/lws-plat-unix.c
@@ -432,7 +432,7 @@ _lws_plat_apply_caps(int mode, cap_value_t *cv, int count)
 #endif
 
 LWS_VISIBLE void
-lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
+lws_plat_drop_app_privileges(const struct lws_context_creation_info *info)
 {
 #if defined(LWS_HAVE_SYS_CAPABILITY_H) && defined(LWS_HAVE_LIBCAP)
 	int n;
@@ -891,7 +891,7 @@ _lws_plat_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount,
 
 LWS_VISIBLE int
 lws_plat_init(struct lws_context *context,
-	      struct lws_context_creation_info *info)
+	      const struct lws_context_creation_info *info)
 {
 	int fd;
 
diff --git a/lib/plat/lws-plat-win.c b/lib/plat/lws-plat-win.c
index 437c4047..13353053 100644
--- a/lib/plat/lws-plat-win.c
+++ b/lib/plat/lws-plat-win.c
@@ -362,7 +362,7 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, lws_sockfd_type fd)
 }
 
 LWS_VISIBLE void
-lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
+lws_plat_drop_app_privileges(const struct lws_context_creation_info *info)
 {
 }
 
@@ -711,7 +711,7 @@ _lws_plat_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount,
 
 LWS_VISIBLE int
 lws_plat_init(struct lws_context *context,
-		  struct lws_context_creation_info *info)
+	      const struct lws_context_creation_info *info)
 {
 	struct lws_context_per_thread *pt = &context->pt[0];
 	int i, n = context->count_threads;
diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index 5a337d13..c6ab7539 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -529,10 +529,10 @@ struct lws_role_ops {
 	int (*check_upgrades)(struct lws *wsi);
 	/* role-specific context init during context creation */
 	int (*init_context)(struct lws_context *context,
-			    struct lws_context_creation_info *info);
+			    const struct lws_context_creation_info *info);
 	/* role-specific per-vhost init during vhost creation */
 	int (*init_vhost)(struct lws_vhost *vh,
-			  struct lws_context_creation_info *info);
+			  const struct lws_context_creation_info *info);
 	/* role-specific per-vhost destructor during vhost destroy */
 	int (*destroy_vhost)(struct lws_vhost *vh);
 	/* generic 1Hz callback for the role itself */
@@ -1231,7 +1231,7 @@ lws_libev_destroyloop(struct lws_context *context, int tsi);
 LWS_EXTERN void
 lws_libev_run(const struct lws_context *context, int tsi);
 #define LWS_LIBEV_ENABLED(context) lws_check_opt(context->options, LWS_SERVER_OPTION_LIBEV)
-LWS_EXTERN void lws_feature_status_libev(struct lws_context_creation_info *info);
+LWS_EXTERN void lws_feature_status_libev(const struct lws_context_creation_info *info);
 #else
 #define lws_libev_accept(_a, _b) ((void) 0)
 #define lws_libev_io(_a, _b) ((void) 0)
@@ -1261,7 +1261,7 @@ lws_libuv_destroyloop(struct lws_context *context, int tsi);
 LWS_EXTERN int
 lws_uv_initvhost(struct lws_vhost* vh, struct lws*);
 #define LWS_LIBUV_ENABLED(context) lws_check_opt(context->options, LWS_SERVER_OPTION_LIBUV)
-LWS_EXTERN void lws_feature_status_libuv(struct lws_context_creation_info *info);
+LWS_EXTERN void lws_feature_status_libuv(const struct lws_context_creation_info *info);
 #else
 #define lws_libuv_accept(_a, _b) ((void) 0)
 #define lws_libuv_io(_a, _b) ((void) 0)
@@ -1759,15 +1759,15 @@ LWS_EXTERN int
 lws_change_pollfd(struct lws *wsi, int _and, int _or);
 
 #ifndef LWS_NO_SERVER
- int _lws_context_init_server(struct lws_context_creation_info *info,
-			    struct lws_vhost *vhost);
+ int _lws_context_init_server(const struct lws_context_creation_info *info,
+			      struct lws_vhost *vhost);
  LWS_EXTERN struct lws_vhost *
  lws_select_vhost(struct lws_context *context, int port, const char *servername);
  LWS_EXTERN int LWS_WARN_UNUSED_RESULT
  lws_parse_ws(struct lws *wsi, unsigned char **buf, size_t len);
  LWS_EXTERN void
  lws_server_get_canonical_hostname(struct lws_context *context,
-				  struct lws_context_creation_info *info);
+				   const struct lws_context_creation_info *info);
 #else
  #define _lws_context_init_server(_a, _b) (0)
  #define lws_parse_ws(_a, _b, _c) (0)
@@ -2055,9 +2055,9 @@ LWS_EXTERN LWS_VISIBLE int
 _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi);
 LWS_EXTERN int
 lws_plat_init(struct lws_context *context,
-	      struct lws_context_creation_info *info);
+	      const struct lws_context_creation_info *info);
 LWS_EXTERN void
-lws_plat_drop_app_privileges(struct lws_context_creation_info *info);
+lws_plat_drop_app_privileges(const struct lws_context_creation_info *info);
 LWS_EXTERN unsigned long long
 time_in_microseconds(void);
 LWS_EXTERN const char * LWS_WARN_UNUSED_RESULT
diff --git a/lib/roles/h2/ops-h2.c b/lib/roles/h2/ops-h2.c
index 01461e1b..f11b461a 100644
--- a/lib/roles/h2/ops-h2.c
+++ b/lib/roles/h2/ops-h2.c
@@ -465,7 +465,7 @@ rops_check_upgrades_h2(struct lws *wsi)
 
 static int
 rops_init_vhost_h2(struct lws_vhost *vh,
-		   struct lws_context_creation_info *info)
+		   const struct lws_context_creation_info *info)
 {
 	int n;
 
@@ -479,7 +479,7 @@ rops_init_vhost_h2(struct lws_vhost *vh,
 
 static int
 rops_init_context_h2(struct lws_context *context,
-		     struct lws_context_creation_info *info)
+		     const struct lws_context_creation_info *info)
 {
 	context->set = lws_h2_stock_settings;
 
diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c
index 4846db9a..d4ec9ebc 100644
--- a/lib/roles/http/server/server.c
+++ b/lib/roles/http/server/server.c
@@ -37,8 +37,8 @@ const char * const method_names[] = {
  */
 
 int
-_lws_context_init_server(struct lws_context_creation_info *info,
-			struct lws_vhost *vhost)
+_lws_context_init_server(const struct lws_context_creation_info *info,
+			 struct lws_vhost *vhost)
 {
 	int n, opt = 1, limit = 1;
 	lws_sockfd_type sockfd;
@@ -272,6 +272,8 @@ done_list:
 			lwsl_info(" Listening on port %d\n", vhost->listen_port);
         }
 
+	// info->port = vhost->listen_port;
+
 	return 0;
 
 bail:
@@ -2588,7 +2590,7 @@ file_had_it:
 
 LWS_VISIBLE void
 lws_server_get_canonical_hostname(struct lws_context *context,
-				  struct lws_context_creation_info *info)
+				  const struct lws_context_creation_info *info)
 {
 	if (lws_check_opt(info->options,
 			LWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME))
diff --git a/lib/roles/ws/ext/extension.c b/lib/roles/ws/ext/extension.c
index 6e1f385d..d20c9568 100644
--- a/lib/roles/ws/ext/extension.c
+++ b/lib/roles/ws/ext/extension.c
@@ -3,7 +3,7 @@
 #include "extension-permessage-deflate.h"
 
 LWS_VISIBLE void
-lws_context_init_extensions(struct lws_context_creation_info *info,
+lws_context_init_extensions(const struct lws_context_creation_info *info,
 			    struct lws_context *context)
 {
 	lwsl_info(" LWS_MAX_EXTENSIONS_ACTIVE: %u\n", LWS_MAX_EXTENSIONS_ACTIVE);
diff --git a/lib/roles/ws/ops-ws.c b/lib/roles/ws/ops-ws.c
index acc20235..f94b0ed6 100644
--- a/lib/roles/ws/ops-ws.c
+++ b/lib/roles/ws/ops-ws.c
@@ -1894,7 +1894,8 @@ rops_callback_on_writable_ws(struct lws *wsi)
 }
 
 static int
-rops_init_vhost_ws(struct lws_vhost *vh, struct lws_context_creation_info *info)
+rops_init_vhost_ws(struct lws_vhost *vh,
+		   const struct lws_context_creation_info *info)
 {
 #if !defined(LWS_WITHOUT_EXTENSIONS)
 #ifdef LWS_WITH_PLUGINS
diff --git a/lib/roles/ws/private.h b/lib/roles/ws/private.h
index 8f81b9e8..1662ec45 100644
--- a/lib/roles/ws/private.h
+++ b/lib/roles/ws/private.h
@@ -143,7 +143,7 @@ lws_ws_handshake_client(struct lws *wsi, unsigned char **buf, size_t len);
 
 #if !defined(LWS_WITHOUT_EXTENSIONS)
 LWS_VISIBLE void
-lws_context_init_extensions(struct lws_context_creation_info *info,
+lws_context_init_extensions(const struct lws_context_creation_info *info,
 			    struct lws_context *context);
 LWS_EXTERN int
 lws_any_extension_handled(struct lws *wsi, enum lws_extension_callback_reasons r,
diff --git a/lib/tls/mbedtls/mbedtls-client.c b/lib/tls/mbedtls/mbedtls-client.c
index 522332f0..fbf0a59c 100644
--- a/lib/tls/mbedtls/mbedtls-client.c
+++ b/lib/tls/mbedtls/mbedtls-client.c
@@ -185,7 +185,7 @@ lws_tls_client_confirm_peer_cert(struct lws *wsi, char *ebuf, int ebuf_len)
 
 int
 lws_tls_client_create_vhost_context(struct lws_vhost *vh,
-				    struct lws_context_creation_info *info,
+				    const struct lws_context_creation_info *info,
 				    const char *cipher_list,
 				    const char *ca_filepath,
 				    const char *cert_filepath,
diff --git a/lib/tls/mbedtls/mbedtls-server.c b/lib/tls/mbedtls/mbedtls-server.c
index 5f3daaa5..d3707f54 100644
--- a/lib/tls/mbedtls/mbedtls-server.c
+++ b/lib/tls/mbedtls/mbedtls-server.c
@@ -207,7 +207,7 @@ lws_tls_server_certs_load(struct lws_vhost *vhost, struct lws *wsi,
 }
 
 int
-lws_tls_server_vhost_backend_init(struct lws_context_creation_info *info,
+lws_tls_server_vhost_backend_init(const struct lws_context_creation_info *info,
 				  struct lws_vhost *vhost, struct lws *wsi)
 {
 	const SSL_METHOD *method = TLS_server_method();
diff --git a/lib/tls/mbedtls/ssl.c b/lib/tls/mbedtls/ssl.c
index 7bf33a01..12c6c168 100644
--- a/lib/tls/mbedtls/ssl.c
+++ b/lib/tls/mbedtls/ssl.c
@@ -28,7 +28,7 @@ lws_ssl_elaborate_error(void)
 }
 
 int
-lws_context_init_ssl_library(struct lws_context_creation_info *info)
+lws_context_init_ssl_library(const struct lws_context_creation_info *info)
 {
 	lwsl_info(" Compiled with MbedTLS support\n");
 
diff --git a/lib/tls/openssl/openssl-client.c b/lib/tls/openssl/openssl-client.c
index 5c5bb489..3e42276f 100644
--- a/lib/tls/openssl/openssl-client.c
+++ b/lib/tls/openssl/openssl-client.c
@@ -320,7 +320,7 @@ lws_tls_client_confirm_peer_cert(struct lws *wsi, char *ebuf, int ebuf_len)
 
 int
 lws_tls_client_create_vhost_context(struct lws_vhost *vh,
-				    struct lws_context_creation_info *info,
+				    const struct lws_context_creation_info *info,
 				    const char *cipher_list,
 				    const char *ca_filepath,
 				    const char *cert_filepath,
diff --git a/lib/tls/openssl/openssl-server.c b/lib/tls/openssl/openssl-server.c
index 0c7f8c92..578376b2 100644
--- a/lib/tls/openssl/openssl-server.c
+++ b/lib/tls/openssl/openssl-server.c
@@ -325,7 +325,7 @@ post_ecdh:
 }
 
 int
-lws_tls_server_vhost_backend_init(struct lws_context_creation_info *info,
+lws_tls_server_vhost_backend_init(const struct lws_context_creation_info *info,
 				  struct lws_vhost *vhost,
 				  struct lws *wsi)
 {
diff --git a/lib/tls/openssl/ssl.c b/lib/tls/openssl/ssl.c
index 14928435..4a2743c8 100644
--- a/lib/tls/openssl/ssl.c
+++ b/lib/tls/openssl/ssl.c
@@ -103,7 +103,8 @@ lws_context_init_ssl_pem_passwd_cb(char * buf, int size, int rwflag,
 }
 
 void
-lws_ssl_bind_passphrase(SSL_CTX *ssl_ctx, struct lws_context_creation_info *info)
+lws_ssl_bind_passphrase(SSL_CTX *ssl_ctx,
+			const struct lws_context_creation_info *info)
 {
 	if (!info->ssl_private_key_password)
 		return;
@@ -117,7 +118,7 @@ lws_ssl_bind_passphrase(SSL_CTX *ssl_ctx, struct lws_context_creation_info *info
 }
 
 int
-lws_context_init_ssl_library(struct lws_context_creation_info *info)
+lws_context_init_ssl_library(const struct lws_context_creation_info *info)
 {
 #ifdef USE_WOLFSSL
 #ifdef USE_OLD_CYASSL
diff --git a/lib/tls/private.h b/lib/tls/private.h
index 890010e9..1038cee1 100644
--- a/lib/tls/private.h
+++ b/lib/tls/private.h
@@ -91,7 +91,7 @@ lws_ssl_capable_write(struct lws *wsi, unsigned char *buf, int len);
 LWS_EXTERN int LWS_WARN_UNUSED_RESULT
 lws_ssl_pending(struct lws *wsi);
 LWS_EXTERN int
-lws_context_init_ssl_library(struct lws_context_creation_info *info);
+lws_context_init_ssl_library(const struct lws_context_creation_info *info);
 LWS_EXTERN int LWS_WARN_UNUSED_RESULT
 lws_server_socket_service_ssl(struct lws *new_wsi, lws_sockfd_type accept_fd);
 LWS_EXTERN int
@@ -117,7 +117,8 @@ lws_ssl_anybody_has_buffered_read_tsi(struct lws_context *context, int tsi);
 LWS_EXTERN int
 lws_gate_accepts(struct lws_context *context, int on);
 LWS_EXTERN void
-lws_ssl_bind_passphrase(lws_tls_ctx *ssl_ctx, struct lws_context_creation_info *info);
+lws_ssl_bind_passphrase(lws_tls_ctx *ssl_ctx,
+			const struct lws_context_creation_info *info);
 LWS_EXTERN void
 lws_ssl_info_callback(const lws_tls_conn *ssl, int where, int ret);
 LWS_EXTERN int
@@ -140,8 +141,8 @@ lws_tls_alloc_pem_to_der_file(struct lws_context *context, const char *filename,
 
 #if !defined(LWS_NO_SERVER)
  LWS_EXTERN int
- lws_context_init_server_ssl(struct lws_context_creation_info *info,
-			    struct lws_vhost *vhost);
+ lws_context_init_server_ssl(const struct lws_context_creation_info *info,
+			     struct lws_vhost *vhost);
  void
  lws_tls_acme_sni_cert_destroy(struct lws_vhost *vhost);
 #else
@@ -161,7 +162,7 @@ lws_ssl_get_error_string(int status, int ret, char *buf, size_t len);
 LWS_EXTERN int
 lws_tls_server_client_cert_verify_config(struct lws_vhost *vh);
 LWS_EXTERN int
-lws_tls_server_vhost_backend_init(struct lws_context_creation_info *info,
+lws_tls_server_vhost_backend_init(const struct lws_context_creation_info *info,
 				  struct lws_vhost *vhost, struct lws *wsi);
 LWS_EXTERN int
 lws_tls_server_new_nonblocking(struct lws *wsi, lws_sockfd_type accept_fd);
@@ -181,7 +182,7 @@ LWS_EXTERN int
 lws_tls_client_confirm_peer_cert(struct lws *wsi, char *ebuf, int ebuf_len);
 LWS_EXTERN int
 lws_tls_client_create_vhost_context(struct lws_vhost *vh,
-				    struct lws_context_creation_info *info,
+				    const struct lws_context_creation_info *info,
 				    const char *cipher_list,
 				    const char *ca_filepath,
 				    const char *cert_filepath,
@@ -193,7 +194,7 @@ LWS_EXTERN int
 lws_ssl_get_error(struct lws *wsi, int n);
 
 LWS_EXTERN int
-lws_context_init_client_ssl(struct lws_context_creation_info *info,
+lws_context_init_client_ssl(const struct lws_context_creation_info *info,
 			    struct lws_vhost *vhost);
 
 LWS_EXTERN void
diff --git a/lib/tls/tls-client.c b/lib/tls/tls-client.c
index 82bdb896..bc10a99f 100644
--- a/lib/tls/tls-client.c
+++ b/lib/tls/tls-client.c
@@ -86,7 +86,7 @@ lws_ssl_client_connect2(struct lws *wsi, char *errbuf, int len)
 }
 
 
-int lws_context_init_client_ssl(struct lws_context_creation_info *info,
+int lws_context_init_client_ssl(const struct lws_context_creation_info *info,
 				struct lws_vhost *vhost)
 {
 	const char *ca_filepath = info->ssl_ca_filepath;
diff --git a/lib/tls/tls-server.c b/lib/tls/tls-server.c
index 1a0f3edc..5cfa0b32 100644
--- a/lib/tls/tls-server.c
+++ b/lib/tls/tls-server.c
@@ -95,7 +95,7 @@ lws_tls_server_conn_alpn(struct lws *wsi)
 }
 
 LWS_VISIBLE int
-lws_context_init_server_ssl(struct lws_context_creation_info *info,
+lws_context_init_server_ssl(const struct lws_context_creation_info *info,
 			    struct lws_vhost *vhost)
 {
 	struct lws_context *context = vhost->context;
@@ -117,11 +117,11 @@ lws_context_init_server_ssl(struct lws_context_creation_info *info,
 	 * provides the vhost SSL_CTX * in the user parameter.
 	 */
 	if (info->ssl_cert_filepath)
-		info->options |= LWS_SERVER_OPTION_CREATE_VHOST_SSL_CTX;
+		vhost->options |= LWS_SERVER_OPTION_CREATE_VHOST_SSL_CTX;
 
 	if (info->port != CONTEXT_PORT_NO_LISTEN) {
 
-		vhost->use_ssl = lws_check_opt(info->options,
+		vhost->use_ssl = lws_check_opt(vhost->options,
 					LWS_SERVER_OPTION_CREATE_VHOST_SSL_CTX);
 
 		if (vhost->use_ssl && info->ssl_cipher_list)
-- 
GitLab