That’s a bit of a loaded question that begs additional questions:
- Is the web server enrolled as an IPA client?
- What format does the private key and certificate need to be in? (OpenSSL-style PEM, NSS, other?)
If the answer to question 1 is YES then you can do this on that client machine (to be clear, this first step can be done anywhere or in the UI):
$ kinit admin$ ipa service-add HTTP/webserver.example.com
You can use certmonger to request and manage the certificate which includes renewals (bonus!).
If you are using NSS and let’s say mod_nss you’d do something like after creating the database and/or putting the password into /etc/httpd/alias/pwdfile.txt:
# ipa-getcert request -K HTTP/webserver.example.com -d /etc/httpd/alias -n MyWebCert -p /etc/httpd/alias/pwdfile.txt -D webserver.example.com
Let’s break down what these options mean:
- -K is the Kerberos principal to store the certificate with. You do NOT need to get a keytab for this service
- -d the NSS database directory. You can use whatever you want but be sure the service has read access and SELinux permission access to it.
- -n the NSS nickname. This is just a shortcut name to your cert, use what you want.
- -p the path to the pin/password for the NSS database
- -D creates a DNS SAN for the hostname webserver.example.com. This is current best practice.
You’ll also need to add the IPA cert chain to the NSS database using certutil.
If you are using OpenSSL and say mod_ssl you’d do something like:
# ipa-getcert request -K HTTP/webserver.example.com -k /etc/pki/tls/private/httpd.key -f /etc/pki/tls/certs/httpd.pem -D webserver.example.com
Similar options as above but instad -f -d and -n:
- -k path to the key file
- -f path to the certificate file
To check on the status of your new request you can run:
# ipa-getcert list -n <numeric id that was spit out before>
It should be in status MONITORING.
If the answer to #1 is NO then you have two options: use certmonger on a different machine to generate the key and certificate and transfer them to the target or generate a CSR manually.
For the first case, using certmonger on a different machine, the steps are similar to the YES case.
Create a host and service for the web server:
$ kinit admin$ ipa host-add webserver.example.com$ ipa service-add HTTP/webserver.example.com
Now we need to grant the rights to the current machine to get certificates for the HTTP service of webserver.example.com
$ ipa service-add-host --hosts <your current machine FQDN> HTTP/webserver.example.com
Now run the appropriate ipa-getcert command above to match the format you need and check the status in a similar way.
Once it’s done you need to transfer the cert and key to the webserver.
Finally, if you want to get certificates on an un-enrolled system the basic steps are:
- Create a host entry and service as above
- Generate a CSR, see https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/linux_domain_identity_authentication_and_policy_guide/certificates#requesting-cert-certutil (or the next section)
- Submit that CSR per the above docs
If your webserver is not registered in DNS then you can use the –force option to host-add and service-add to force their creation.
This should pretty generically apply to all versions of IPA v4+, and probably to v3 as well.