So I just got my certificate issued from Digicert, and since there was other unused/old files in /etc/ssl/ i marked and removed, and accidently also removed localhost.crt.
Now I cannot start my web server (only without SSL). How do i recreate this localhost.crt file? And would i need to make a new key and get my certificate from digicert reissued?
There are two solutions to this issue:
1) You can regenerate the default self-signed certificate using OpenSSL:
2) You can search the Apache config files and replace the self-signed cert with the new certificate.
This command will tell you which Apache config files reference the localhost.crt file:
An example output of the above command might be this:
That tells us to look in /etc/httpd/conf.d/ssl.conf and update the SSLCertificateFile, SSLCertificateKeyFile, and SSLCertificateChainFile to their new DigiCert certificate files.
Please feel free to call DigiCert support at 1-801-701-9600 if you have any problems or questions.
The files
/etc/pki/tls/certs/localhost.crt
and/etc/pki/tls/private/localhost.key
are created by the postinstall script of themod_ssl
package. You can find the CentOS 7 spec file here: https://git.centos.org/rpms/httpd/blob/c7/f/SPECS/httpd.spec (check the other branches for different CentOS versions). Here is the script from CentOS 7:So if you delete both
localhost.key
andlocalhost.crt
, and doyum reinstall mod_ssl
, then the postinstall script will recreate them for you.(I'm posting this answer because searching how to recreate
/etc/pki/tls/certs/localhost.crt
leads me here, but as others stated, if you got a cert signed by a CA, you don't need thelocalhost.crt
andlocalhost.key
files any more.)your ssl certificate issuer should provide you free replacement or reissue. Just go to digicert and ask them.
Generate new key files from server and reissue ssl. Make sure the new ssl should be SHA2 only.
I just had this same problem. There was no default localhost certificate for CentOS 8 so I ran this and it regenerated all the default certs.
Hope it helps someone else.
You can just reinstall ssl with following command.It will regenerate localhost.crt
yum -y install mod_ssl