Prechádzať zdrojové kódy

mg_connect_client should set SNI for HTTPS connections

see https://github.com/civetweb/civetweb/issues/1045#issuecomment-997165735
bel2125 3 rokov pred
rodič
commit
a268f2fe07
2 zmenil súbory, kde vykonal 5 pridanie a 2 odobranie
  1. 2 2
      examples/client/client.c
  2. 3 0
      src/civetweb.c

+ 2 - 2
examples/client/client.c

@@ -37,8 +37,8 @@ main(int argc, char *argv[])
 	/* Connect client */
 	char errbuf[256] = {0};
 	struct mg_client_options opt = {0};
-	opt.host = argv[1]; /* Host name from command line */
-	opt.port = 443;     /* Default HTTPS port */
+	opt.host = argv[1];       /* Host name from command line */
+	opt.port = 443;           /* Default HTTPS port */
 	opt.client_cert = NULL;   /* Client certificate, if required */
 	opt.server_cert = NULL;   /* Server certificate to verify */
 	opt.host_name = opt.host; /* Host name for SNI */

+ 3 - 0
src/civetweb.c

@@ -17982,6 +17982,9 @@ mg_connect_client(const char *host,
 	memset(&opts, 0, sizeof(opts));
 	opts.host = host;
 	opts.port = port;
+	if (use_ssl) {
+		opts.host_name = host;
+	}
 	return mg_connect_client_impl(&opts,
 	                              use_ssl,
 	                              error_buffer,