{"id":1391,"date":"2018-01-29T09:49:58","date_gmt":"2018-01-29T15:49:58","guid":{"rendered":"https:\/\/it.thelibrarie.com\/weblog\/?p=1391"},"modified":"2018-01-29T09:49:58","modified_gmt":"2018-01-29T15:49:58","slug":"unifi-linux-and-windows-certificates","status":"publish","type":"post","link":"https:\/\/it.thelibrarie.com\/weblog\/2018\/01\/unifi-linux-and-windows-certificates\/","title":{"rendered":"Unifi Linux and Windows Certificates"},"content":{"rendered":"<p>I thought I knew it all about certificates, but then I was humbled once again.<\/p>\n<p>I needed to &#8220;secure&#8221; an internal linux webserver using our Windows 2016 CA as to remove the &#8220;this is an unverified site&#8221; messages that liked to pop up when browsing the various sites.<\/p>\n<p>The process I had done in the past was to create the CSR using openssl, then copy the encryption data, open up my trusty http:\/\/certserverhere\/certsrv\/ site and go through the process of making a webserver certificate. Then, when finished, just download the certificate and the CA + chain, import on linux, and profit.<\/p>\n<p>Well, the new versions of the templates (V3 and V4 specifically) no longer allowed the web enrollment using my trusty http:\/\/certserverhere\/certsrv site. Booo.<\/p>\n<p>I could probably get it to work by just requesting my own certificates using the MMC, but I&#8217;m still leaning towards the whole CLI phase of life. I should also note that I find the performance and management of Unifi on Linux to be significantly better and easier than that on Windows. YMMV.<\/p>\n<p>By the way, this is technically how I published a certificate on our Unifi wireless controller. The CA Certificate Authority is a 2016 Windows Server that&#8217;s been published in AD. The unifi machine is running Ubuntu 17.10 and unifi version 5.6.29. I also used WinSCP, Putty, and my base machine is Win10 (not super applicable).<\/p>\n<p><strong>SSH to the Unifi Machine<\/strong><br \/>\n(I did this as root, so add &#8220;sudo&#8221; before commands if you&#8217;re not the root god)<br \/>\n<code>cd \/usr\/lib\/unifi<\/code><br \/>\n<code>java -jar lib\/ace.jar new_cert unifi.domain.tld CompanyName Town State Country<\/code><br \/>\nThis creates unifi_certificate.csr.der and unifi_certificate.csr.pem &#8211; the DER is encrypted and the PEM is what we need.<\/p>\n<p><strong>Get the PEM over to your CA Server<\/strong><br \/>\nI just used nano to view all the data and then copy pasted, but feel free to WinSCP it over as well<br \/>\n<code>nano unifi_certificate.csr.pem<\/code><br \/>\nCopy this text, then on the CA create a new text file and paste the data there. Save.<\/p>\n<p><strong>Certreq<\/strong><br \/>\nOpen an administrative Command Prompt on your CA server<br \/>\n<code>certreq -submit -attrib \"SAN:dns=unifi.yourdomain.tld&dns=unifi\" -attrib \"CertificateTemplate:WebServer2018\" unifi_certificate.csr.pem<\/code><br \/>\nBy default your Certificate Template will be &#8220;WebServer&#8221; instead of the one I listed above &#8211; I created my own template with the year it&#8217;s valid for the sake of record keeping.<\/p>\n<p><strong>Save the Certificate<\/strong><br \/>\nAssuming the request went through, you&#8217;ll be able to name and save your signed certificate. In my case I named it unifi_withSAN.domain.tld.cer. I also navigated to the http:\/\/certserverhere\/certsrv site and downloaded the CA certificate, Certificate chain, or CRL (I just downloaded the CA Certificate as it&#8217;s a single host with no subs).<\/p>\n<p><strong>Copy it back to Unifi<\/strong><br \/>\nI used WinSCP to copy both the signed certificate as well as the CA Certificate I downloaded back to my \/home directory on the Unifi server.<\/p>\n<p><strong>Final Touches<\/strong><br \/>\nBack on your Unifi SSH session (in the \/usr\/lib\/unifi directory)<br \/>\n<code>java -jar lib\/ace.jar import_cert \/home\/unifi_withSAN.domain.local.cer \/home\/srv-cert01-ca.cer<\/code><br \/>\nReplace srv-cert01-ca with the name of your CA certificate.<br \/>\nIf successful, restart the unifi services<br \/>\n<code>service unifi restart<\/code><\/p>\n<p>Close your browser and open back up to https:\/\/unifi:8443 and no more error!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I thought I knew it all about certificates, but then I was humbled once again. I needed to &#8220;secure&#8221; an internal linux webserver using our Windows 2016 CA as to remove the &#8220;this is an unverified site&#8221; messages that liked to pop up when browsing the various sites. The process I had done in the &hellip; <a href=\"https:\/\/it.thelibrarie.com\/weblog\/2018\/01\/unifi-linux-and-windows-certificates\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Unifi Linux and Windows Certificates<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,1,4],"tags":[],"class_list":["post-1391","post","type-post","status-publish","format-standard","hentry","category-linux","category-miscellaneous","category-networking"],"_links":{"self":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/1391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/comments?post=1391"}],"version-history":[{"count":1,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/1391\/revisions"}],"predecessor-version":[{"id":1392,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/1391\/revisions\/1392"}],"wp:attachment":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/media?parent=1391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/categories?post=1391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/tags?post=1391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}