Generating certificate requests for OpenSSL with ADCS
[Prereq] Install WSL on a supported windows 10 pro or enterprise workstation (min build 1607, preferred 1709 or later)
- Open programs and features in control panel
- Open "turn windows features on or off"
- Enable windows subsystem for linux.
- Reboot after install.
- [builds 1607 and 1703]
- Open cmd
- Call [bash] from within cmd and follow the setup instructions that follow.
- After the environment is installed, run [sudo apt update && sudo apt upgrade] to pull all of the current security updates and bugfixes from canonical.
[builds 1709 and later]
- Open the windows store
- Search for ubuntu
- Install the ubuntu module for WSL from Canonical Group Limited
Note on 1709 nov. update.:
Steps 1-4 can be accomplished using
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
In powershell
Creating SSL Cert using OpenSSL
- Change to a preferred working directory. I prefer to work within the windows filesystem for easier access to the files when I am done. The windows filesystem can be found within WSL mounted under "/mnt/c/" I personally prefer to work in my user directory/desktop, which for me is /mnt/c/Users/sethk/Desktop
- Create a new working directory to create the cert. Eg: [mkdir spiceworks_ssl] then CD to it.
- Create a file ssl.cnf
- My preferred method is to create and edit using nano. Create the document with "nano ssl.cnf" and paste the contents in. adjust the fields to match the server needing the ssl cert and save with control-x. The ssl.cnf used for the spiceworks server is attached for reference.
- Create a new private key. I prefer 2048 bit keys as they still provide decent security without impacting performance.
- Run [openssl req -new -nodes -keyout private.key -out server.csr -config ssl.cnf]
- This will generate two files. private.key and server.csr .We will use the server.csr to generate a signed public key with a trusted CA, in this case ADCS.
- Dump the contents of server.csr to the terminal. [ cat server.csr ]
- Select the text between -------BEGIN …. And REQUEST-------- and hit enter to copy to the clipboard.
- Go to the ADCS server in a browser (preferrably firefox, IE defaults to installing certs instead of downloading them. In our case it is at http://ADCS.xenos.local/certsrv/
- Select request a certificate
- Select a advanced certificate request
- Enter the server.csr contents into the base64 request. Most use cases will use the webserver template.
- Submit the request.
- You should now be able to download the cert. NOTE: MOST NON-MICROSOFT APPLICATIONS (eg. Apache) REQUIRE BASE 64 ENCODING
- You now have a signed public/private key pair
Endnote: Most applications will allow you to directly overwrite the default keys. The easiest way to do this is to dump the contents of both files eg. Cat private.key and cat /mnt/c/Users/sethk/Downloads/certnew.cer . Copy the contents over their respective counterparts on the destination server (after making a checkpoint/backup).
Example Contents for ssl.cnf
-----------------------
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no
[req_distinguished_name]
C = US
ST = WA
L = Washington
O = Xenos
OU = IT
CN = Xenos.local
[v3_req]
keyUsage = keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = spiceworks.xenos.local
DNS.2 = spiceworks