Browse Source

Test the test: OpenSSL / Apple / TravisCI

It seems to be possible to connect to a HTTPS server on Apple/TravisCI without any client certificate, although the server is configured to require a valid client certificate. The same configuration works on all other systems. The Travis/Apple-OpenSSL configuration requires to use an old protocol version, maybe this is related and due to an outdated test image in the CI.
bel2125 5 năm trước cách đây
mục cha
commit
8eec8c150e
1 tập tin đã thay đổi với 18 bổ sung0 xóa
  1. 18 0
      unittest/public_server.c

+ 18 - 0
unittest/public_server.c

@@ -786,6 +786,24 @@ START_TEST(test_mg_server_and_client_tls)
 	    mg_connect_client("127.0.0.1", 8443, 1, client_err, sizeof(client_err));
 
 	/* cannot connect without client certificate */
+#if defined(__MACH__)
+	/* except for Apple ????? - Maybe this is specific to TravisCI */
+	if (conn) {
+		mg_printf(client_conn, "GET / HTTP/1.0\r\n\r\n");
+		client_res =
+		    mg_get_response(client_conn, client_err, sizeof(client_err), 10000);
+		ck_assert_int_ge(client_res, 0);
+		ck_assert_str_eq(client_err, "");
+		client_ri = mg_get_response_info(client_conn);
+		ck_assert(client_ri != NULL);
+		
+		ck_abort_msg("Connected to a host without valid client cert. Server response: %u", client_ri->status_code);
+		
+		mg_close_connection(client_conn);
+		client_conn == NULL;
+		strcpy(client_err, "OpenSSL on MacOS");
+	}
+#endif
 	ck_assert(client_conn == NULL);
 	ck_assert_str_ne(client_err, "");