{"id":2073,"date":"2019-02-18T20:38:55","date_gmt":"2019-02-18T19:38:55","guid":{"rendered":"http:\/\/labalec.fr\/erwan\/?p=2073"},"modified":"2021-11-01T15:39:36","modified_gmt":"2021-11-01T14:39:36","slug":"build-a-lightweigth-https-server-step-4","status":"publish","type":"post","link":"https:\/\/labalec.fr\/erwan\/?p=2073","title":{"rendered":"Build a lightweigth HTTPS server : step 4"},"content":{"rendered":"<p>Last article of <a href=\"https:\/\/labalec.fr\/erwan\/?p=2036\" target=\"_blank\" rel=\"noopener\">a series of 4 articles<\/a>.<\/p>\n<p>This time, we will push it a bit further on the certificate side (using SAN field) as modern browsers like Chrome demand this field :<\/p>\n<p>-divert dns traffic to a rogue local dns server : see <a href=\"https:\/\/labalec.fr\/erwan\/?p=2063\" target=\"_blank\" rel=\"noopener\">here<\/a><\/p>\n<p>-spoof a remote hostname with our local ip (using tool in step above) &#8211; these 2 steps could be skipped if you modify your local hosts file.<\/p>\n<p>-setup a https server locally with a \u00ab\u00a0self signed\u00a0\u00bb certificate (see below)<\/p>\n<p>First our root ca (dont forget to add in your ca store):<br \/>\n<strong>openssl genrsa -out rootCA.key 2048<br \/>\nopenssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem<\/strong><br \/>\nLets add it to our root certificate authorities : <strong>certutil -enterprise -f -v -addstore \u00ab\u00a0root\u00a0\u00bb rootCA.pem<\/strong><\/p>\n<p>Second our CSR:<br \/>\nmodify our openssl.cnf accordingly : add subjectAltName=DNS:fakedomain.com,DNS:*.fakedomain.com under section v3_req<br \/>\nset the path to your your cnf file with <strong>set OPENSSL_CONF=c:\\_apps\\OpenSSL\\ssl\\openssl.cnf<\/strong><br \/>\ngenerate your csr<br \/>\n<strong>openssl genrsa -out device.key 2048<br \/>\nopenssl req -new -key device.key -out fakedomain.csr <\/strong><br \/>\nAbout the CN, enter \u00ab\u00a0fakedomain.com\u00a0\u00bb<\/p>\n<p>Last, our CRT (the trick is is to point at your cnf or else the SAN field will not be taken care of)<br \/>\n<strong>openssl x509 -req -in fakedomain.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out fakedomain.crt -days 500 -sha256 -extfile c:\\_apps\\openssl\\ssl\\openssl.cnf<\/strong><\/p>\n<p>And tada, launch your chrome browser and browse https:\/\/www.fakedomain.com\/ and chrome will be happy.<\/p>\n<p>note:<\/p>\n<p>alternative to create a server cert:<\/p>\n<p>openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -keyout rsaprivate.key -out servercertificate.crt<\/p>\n<p>cat rsaprivate.key servercertificate.crt &gt; my.pem<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last article of a series of 4 articles. This time, we will push it a bit further on the certificate side (using SAN field) as modern browsers like Chrome demand this field : -divert dns traffic to a rogue local dns server : see here -spoof a remote hostname with our local ip (using tool <a href='https:\/\/labalec.fr\/erwan\/?p=2073' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2073","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-1-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/2073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2073"}],"version-history":[{"count":6,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/2073\/revisions"}],"predecessor-version":[{"id":2328,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/2073\/revisions\/2328"}],"wp:attachment":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2073"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}