{"id":5196,"date":"2026-04-09T14:44:22","date_gmt":"2026-04-09T05:44:22","guid":{"rendered":"https:\/\/www.freelifemakers.org\/wordpress\/?p=5196"},"modified":"2026-04-09T15:16:48","modified_gmt":"2026-04-09T06:16:48","slug":"webserver-httplib-https1-macos-linux","status":"publish","type":"post","link":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2026\/04\/09\/webserver-httplib-https1-macos-linux\/","title":{"rendered":"[Webserver]httplib webserver+https(openssl)(1)(MacOS,Linux)"},"content":{"rendered":"\n<p>\ud83d\udc49\ud83c\udffb http_lib \uc11c\ubc84\uc5d0 openssl\ub97c \uc0ac\uc6a9\ud574\uc11c \ud14c\uc2a4\ud2b8\uc6a9 \uc778\uc99d\uc11c\ub97c \ubc1b\uc544\uc11c https\ub97c \uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc785\ub2c8\ub2e4.<br>This is a method to use HTTPS by obtaining a test certificate using openssl on the http_lib server.<\/p>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb \uc544\ub798\ub294 MacOS\uc640 Linux\uc5d0\uc11c \uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc785\ub2c8\ub2e4.<br>Below is how to use it on MacOS and Linux.<\/p>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb Open SSL<\/p>\n\n\n\n<p>\u2714\ufe0f Let&#8217;s Encrypt\uac19\uc740 \uacf5\uc778\uc778\uc99d\uc11c\uac00 \uc544\ub2cc \uc2a4\uc2a4\ub85c \ub9cc\ub4dc\ub294 \uc778\uc99d\uc11c\uc785\ub2c8\ub2e4.<br>It is a certificate that you create yourself, not an accredited certificate like Let&#8217;s Encrypt.<\/p>\n\n\n\n<p>\u2714\ufe0f \uacf5\uc778\uc778\uc99d\uc774 \uc544\ub2c8\uae30 \ub54c\ubb38\uc5d0 \ube0c\ub77c\uc6b0\uc800 \uc811\uc18d\uc2dc https:\/\/\uc5d0 \ube68\uac04\uc904\uc774 \ub739\ub2c8\ub2e4.<br>Since it is not an accredited certificate, a red line appears under https:\/\/ when accessing via a browser.<\/p>\n\n\n\n<p>\u2714\ufe0f https\ud14c\uc2a4\ud2b8 \uc6a9\uc73c\ub85c \uc0ac\uc6a9\uac00\ub2a5\ud558\uba70 \uc2e4\uc81c \uc11c\ube44\uc2a4\uc5d0\uc11c\ub294 Let&#8217;s Encrypt\uac19\uc740 \uacf5\uc778\uc778\uc99d\uc11c\uac00 \ud544\uc694\ud569\ub2c8\ub2e4.<br>It can be used for HTTPS testing, but an accredited certificate like Let&#8217;s Encrypt is required for actual services.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\ud83d\udc49\ud83c\udffbopenssl \uc124\uce58 \/ install openssl<\/p>\n\n\n\n<p>\u2714\ufe0fMacOS<\/p>\n\n\n\n<p>&#8212; Open SSL\uc124\uce58 \/ install openssl<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>brew install openssl<\/code><\/pre>\n\n\n\n<p>&#8212; \ud14c\uc2a4\ud2b8\uc6a9 \uc778\uc99d\uc11c\uc640 \ud0a4\ud30c\uc77c \uc0dd\uc131(<code>cert.pem<\/code> , <code>key.pem<\/code>)<br>Generate test certificate and key file (cert.pem, key.pem)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes<\/code><\/pre>\n\n\n\n<p>\u2714\ufe0f Linux<\/p>\n\n\n\n<p>&#8212; Open SSL\uc124\uce58 \/ Install Open SSL<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install g++ libssl-dev openssl wget -y<\/code><\/pre>\n\n\n\n<p>&#8212; \ud14c\uc2a4\ud2b8\uc6a9 \uc778\uc99d\uc11c\uc640 \ud0a4\ud30c\uc77c \uc0dd\uc131(<code>cert.pem<\/code> , <code>key.pem<\/code>)<br>Generate test certificate and key file (cert.pem, key.pem)<\/p>\n\n\n\n<p>\u2b50\ufe0f CN=localhost\ub77c\ub3c4 \uc0ac\uc6a9\uac00\ub2a5 \ub3c4\uba54\uc778\uc774 \uc788\ub2e4\uba74 \ub3c4\uba54\uc778 \uc785\ub825\ud560\uac83(CN=host.domain.org)<br>If you have a usable domain even if CN=localhost, enter the domain (CN=host.domain.org)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj \"\/C=KR\/ST=Seoul\/L=Seoul\/O=MyOrg\/OU=IT\/CN=localhost\"<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb httplib.h \ub2e4\uc6b4\ub85c\ub4dc \/ httplib.h Download<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -L https:\/\/raw.githubusercontent.com\/yhirose\/cpp-httplib\/master\/httplib.h -o httplib.h<\/code><\/pre>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb server.cpp <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define CPPHTTPLIB_OPENSSL_SUPPORT\n#include \"httplib.h\"\n#include &lt;iostream>\n\nint main( ) {\n    \/\/ \uc778\uc99d\uc11c\uc640 \ud0a4 \ud30c\uc77c \uacbd\ub85c\ub97c \uc9c0\uc815\ud569\ub2c8\ub2e4.\n    \/\/ Specify the certificate and key file paths.\n    httplib::SSLServer svr(\".\/cert.pem\", \".\/key.pem\" );\n\n    if (!svr.is_valid()) {\n        std::cerr &lt;&lt; \"SSL \uc11c\ubc84 \uc124\uc815 \uc2e4\ud328 \/ SSL server setup failed!\" &lt;&lt; std::endl;\n        return 1;\n    }\n\n    svr.Get(\"\/\", &#91;](const httplib::Request&amp;, httplib::Response&amp; res ) {\n        res.set_content(\"&lt;h1> \ud83d\udc49\ud83c\udffb HTTPS Server is Running! \ud83d\udd25 &lt;\/h1>\", \"text\/html; charset=utf-8\");\n    });\n\n    std::cout &lt;&lt; \"Server Listening: https:\/\/0.0.0.0:5080\" &lt;&lt; std::endl;\n    svr.listen(\"0.0.0.0\", 5080 );\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb \ucef4\ud30c\uc77c \/ Compiling<\/p>\n\n\n\n<p>\u2714\ufe0f MacOS<\/p>\n\n\n\n<p>&#8212; Apple Silicon(M1,M2,M3)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>g++ -o server server.cpp -std=c++11 -pthread \\\n-I\/opt\/homebrew\/opt\/openssl\/include \\\n-L\/opt\/homebrew\/opt\/openssl\/lib \\\n-lssl -lcrypto<\/code><\/pre>\n\n\n\n<p>&#8212; Intel<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>g++ -o server server.cpp -std=c++11 -pthread \\\n-I\/usr\/local\/opt\/openssl\/include \\\n-L\/usr\/local\/opt\/openssl\/lib \\\n-lssl -lcrypto<\/code><\/pre>\n\n\n\n<p>&#8212; \uac04\ub2e8\ud788 pkg-config \uc0ac\uc6a9\uac00\ub2a5 \/ You can simply use pkg-config.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>g++ -o server server.cpp -std=c++11 -pthread $(pkg-config --cflags --libs openssl)<\/code><\/pre>\n\n\n\n<p>\u2714\ufe0f Linux<\/p>\n\n\n\n<p>\u2b50\ufe0f \ub9ac\ub205\uc2a4\uc5d0\uc11c \ucef4\ud30c\uc77c\uc2dc warning \ubb38\uad6c\uac00 \ub730 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc2e4\ud589\ud30c\uc77c\uc740 \uc0dd\uc131\ub418\ub2c8 \ubb34\uc2dc\ud558\uace0 \uc0ac\uc6a9\ud558\uc2dc\uba74 \ub429\ub2c8\ub2e4.<br>Warning messages may appear when compiling on Linux. An executable file will be generated, so you can ignore them and use the application.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>g++ -o server server.cpp -std=c++11 -pthread -lssl -lcrypto<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb \uc11c\ubc84 \uc2e4\ud589 \/ Run Server<\/p>\n\n\n\n<p>\u2714\ufe0f macOS &amp; Linux<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/server<\/code><\/pre>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb \ube0c\ub77c\uc6b0\uc800 \uc811\uc18d \/ Browser access<\/p>\n\n\n\n<p>\u2714\ufe0f macOS<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1022\" height=\"450\" src=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/mac.jpg\" alt=\"\" class=\"wp-image-5199\" srcset=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/mac.jpg 1022w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/mac-300x132.jpg 300w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/mac-768x338.jpg 768w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/mac-400x176.jpg 400w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/mac-800x352.jpg 800w\" sizes=\"auto, (max-width: 1022px) 100vw, 1022px\" \/><figcaption class=\"wp-element-caption\">Chrome browser,MacOS<\/figcaption><\/figure>\n\n\n\n<p>\u2714\ufe0f Linux<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"410\" src=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/linux-1024x410.jpg\" alt=\"\" class=\"wp-image-5201\" srcset=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/linux-1024x410.jpg 1024w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/linux-300x120.jpg 300w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/linux-768x307.jpg 768w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/linux-400x160.jpg 400w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/linux-800x320.jpg 800w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/linux.jpg 1060w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Chrome browser,Linux<\/figcaption><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u2b50\ufe0f \ud06c\ub86c \ube0c\ub77c\uc6b0\uc800 \uc811\uc18d\uc2dc <strong>localhost(\uc548\uc804\ud558\uc9c0 \uc54a\uc74c)\uc73c\ub85c \uc774\ub3d9]<\/strong> \ubc84\ud2bc\uc774 \ub098\ud0c0\ub098\uc9c0 \uc54a\ub294 \uacbd\uc6b0<br>If the [Go to localhost (unsafe)] button does not appear when accessing via Chrome browser<\/p>\n\n\n\n<p>\ube0c\ub77c\uc6b0\uc800\uc5d0 \uc800\uc7a5\ub41c HSTS \uc124\uc815 \uc0ad\uc81c<br>Delete HSTS settings saved in the browser<\/p>\n\n\n\n<p>\ub9cc\uc57d \uc704 \ubc29\ubc95\uc774 \uc791\ub3d9\ud558\uc9c0 \uc54a\ub294\ub2e4\uba74, \ube0c\ub77c\uc6b0\uc800\uac00 \uae30\uc5b5\ud558\uace0 \uc788\ub294 \ud574\ub2f9 \ub3c4\uba54\uc778\uc758 \ubcf4\uc548 \uc815\ucc45\uc744 \uac15\uc81c\ub85c \uc9c0\uc6cc\uc57c \ud569\ub2c8\ub2e4.\u00a0<br>If the above method does not work, you must forcibly clear the security policy for the domain that the browser remembers.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1)\ud06c\ub86c \uc8fc\uc18c\ucc3d\uc5d0\u00a0chrome:\/\/net-internals\/#hsts\ub97c \uc785\ub825\ud558\uace0 \uc811\uc18d\ud569\ub2c8\ub2e4.\nEnter chrome:\/\/net-internals\/#hsts into the Chrome address bar and access it.\n\n2)\ub9e8 \uc544\ub798\u00a0Delete domain security policies\u00a0\ud56d\ubaa9\uc744 \ucc3e\uc2b5\ub2c8\ub2e4.\nLocate the \"Delete domain security policies\" item at the very bottom.\n\n3)Domain\u00a0\uce78\uc5d0\u00a0(ex.) localhost \ub610\ub294 host.domain.org\ub97c \uc785\ub825\ud558\uace0\u00a0Delete\u00a0\ubc84\ud2bc\uc744 \ub204\ub985\ub2c8\ub2e4.\nEnter (e.g.) localhost or host.domain.org in the Domain field and click the Delete button.<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\udc49\ud83c\udffb http_lib \uc11c\ubc84\uc5d0 openssl\ub97c \uc0ac\uc6a9\ud574\uc11c \ud14c\uc2a4\ud2b8\uc6a9 \uc778\uc99d\uc11c\ub97c \ubc1b\uc544\uc11c https\ub97c \uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc785\ub2c8\ub2e4.This is a method to use HTTPS by obtaining a test certificate using openssl on the http_lib server. \ud83d\udc49\ud83c\udffb \uc544\ub798\ub294 MacOS\uc640 Linux\uc5d0\uc11c \uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc785\ub2c8\ub2e4.Below is how to use it on MacOS and Linux. \ud83d\udc49\ud83c\udffb Open SSL \u2714\ufe0f Let&#8217;s Encrypt\uac19\uc740 \uacf5\uc778\uc778\uc99d\uc11c\uac00 \uc544\ub2cc \uc2a4\uc2a4\ub85c \ub9cc\ub4dc\ub294 \uc778\uc99d\uc11c\uc785\ub2c8\ub2e4.It is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,1],"tags":[],"class_list":["post-5196","post","type-post","status-publish","format-standard","hentry","category-cpp","category-uncategorized","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/5196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=5196"}],"version-history":[{"count":21,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/5196\/revisions"}],"predecessor-version":[{"id":5220,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/5196\/revisions\/5220"}],"wp:attachment":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=5196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=5196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=5196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}