As I mentioned here I’ve
been having problems with my Windows CA. I’ve now managed to get an OpenSSL CA
up and running and I’m able to get my Windows box to accept the certs/keys.
This is how I did it.
First make sure all tools are available. You’ll need openssl, make, and some
way of getting the generated certs/keys from your CA machine to your server, I
use SSH for that.
I used this site as inspiration. I
changed the policy to the more accepting policy_anything and I changed
the description of my CA in root_ca_distinguished_name. After that I ran
make init to create the CA cert and key.
$ make init
Generating a 2048 bit RSA private key
........+++
.................................+++
writing new private key to './private/ca-key.pem'
-----
Quite a few new directories and files have been created:
$ tree
.
|-- Makefile
|-- ca-cert.pem
|-- crl
|-- index
|-- newcerts
|-- openssl.cnf
|-- private
| `-- ca-key.pem
`-- serial
3 directories, 6 files
We’ll convert the CA’s certificate (ca-cert.pem) to a format that Windows
can use right away, we’ll need it later:
$ openssl x509 -in ca-cert.pem -outform der -out ca-cert.der
Now it’s time to create a certificate signing request (CSR). To impose some
order I created a dir to keep my client-related stuff in, $ mkdir -p
client/svc01. After changing into the client dir I create a CSR:
$ openssl req -newkey rsa:2048 -keyout svc01_priv.pem -keyform pem \
-out svc01.csr -outform pem
A few questions are asked about the cert/key (remember that the common name
should be the FQDN of the server), and a password for the private key is
required (at least four characters long). The CSR is saved to svc01.csr. Now
change back to the CA top directory and copy the CSR here. Then run make
sign to issue the certificate. The cert ends up in svc01.cert, move it down
to the client directory ($ mv svc01.cert client/svc01/svc01_cert.pem, since
I’m using the CA to issue certificates for Windows servers I like to make the
file format explicit).
Now that we have the signed certificate, svc01_cert.pem, and the private
key, svc01_priv.pem, we need to package them both in a PKCS12 file so that
Windows can use them:
$ openssl pkcs12 -export -inkey svc01_priv.pem -in svc01_cert.pem \
-out svc01_CertNKey_p12.cer
You’ll have to enter the password to unlock the private key, you’ll also have
to enter the password to be used for exporting the private key out of the
resulting file later on (I like leaving it empty). Copy the file to the
Windows machine and change its suffix to .pfx, now you should be able to
import the key and cert. In order to use the key you’ll also have to install
your CA’s cert (ca-cert.der).