How to export a private key from a Godaddy certificate and use it with Apache SSL

I purchased a Godaddy certificate, I installed it correctly on my Mac server, so now I see 2 entries in the Keychain application:

  • Go Daddy Secure Certificate Authority
  • MYDOMAIN
    • mydomain (private key)

Then I added the certificate (mydomain.com) to the VirtualHost of the httpd.conf file, so:

<VirtualHost *:443> DocumentRoot "/Library/ApacheTomcat/apache-tomcat-6.0.33/webapps/MyServerAppName" ServerName mydomain.com ErrorLog "/private/var/log/apache2/mydomain.com-error_log" CustomLog "/private/var/log/apache2/mydomain.com-access_log" common SSLCertificateFile /etc/apache2/mydomain.cer JkMountCopy On JkMount /* ajp13 </VirtualHost> 

Then, I think, I also need a private key file, otherwise Apache will not be able to process the certificate. How to do it? I can save certificates from Apple Keychain to .pem and .cer files.

+4
source share
2 answers

In the keychain, export your private key and certificate in PKCS # 12 format (.p12 file, Personal Information Exchange). You must do this by expanding your private key (in Keychain Access), right-clicking its certificate and using Export. You will probably ask for a password to protect this p12 file.

Then in the terminal, extract the private key using OpenSSL:

  umask 0077 openssl pkcs12 -in filename.p12 -nocerts -nodes -out filename-key.pem umask 0022 
  • Note that you must protect this file since the private key will not be password protected (so it can be used by Apache Httpd).

Similarly, for the certificate (although it seems that you already have it in PEM format, so you may not need this step):

  openssl pkcs12 -in filename.p12 -clcerts -nokeys -out filename-cert.pem 

Then set the SSLCertificateFile (cert) and SSLCertificateKeyFile (private key) to point to these files in your Apache Httpd configuration.

+8
source

I had the same problem and I used these commands to export the private key

 umask 0077 openssl pkcs12 -in filename.p12 -nocerts -nodes -out filename-key.pem umask 0022 

and to export the certificate

 openssl pkcs12 -in filename.p12 -clcerts -nokeys -out filename-cert.pem 
0
source

Source: https://habr.com/ru/post/1384967/


All Articles