Difference between revisions of "4.x Commercial Certificates Guide"

(19 intermediate revisions by 6 users not shown)
Line 1: Line 1:
=FOR 5.x servers, please do not use this page, use [[Commercial_Certificate_in_5.x]] instead=
{{Archive}}{{Article Infobox|{{admin}}|||{{ZCS 4.5}}}}=FOR 5.x servers, please do not use this page=
* use [[Commercial_Certificate_in_5.x]] instead
* use [[Commercial_Certificate_in_5.x]] instead
Line 8: Line 8:
== Using a pre-existing certificate from another server ==
== Using a pre-existing certificate from another server ==
If you already have an "apache style" PEM or DER format certificate for this server hostname, and want to re-use it, [http://www.zimbra.com/forums/showthread.php?t=4738 this forum thread] has been condensed to the [[Commercial_Certificates#PEM_Format_Commercial_SSL_Cert_Install_Procedure|PEM format certificate conversion]] section below.
If you already have an "apache style" PEM or DER format certificate for this server hostname, and want to re-use it, [http://www.zimbra.com/forums/showthread.php?t=4738 this forum thread] has been condensed to the [[4.x_Commercial_Certificates_Guide#PEM_Format_Commercial_SSL_Cert_Install_Procedure|PEM format certificate conversion]] section below.
== Getting a certificate for MTA ==
If you are installing a commcercial certificate for the MTA and or LDAP, you can simply
acquire a certificate for postfix in "PEM" format and save the signed cert and the key
in /opt/zimbra/conf directory and reload postfix
== Generate a certificate signing request (CSR) for tomcat ==
== Generate a certificate signing request (CSR) for tomcat ==
Line 255: Line 259:
== Generate a CSR for tomcat ==
== Generate a CSR for tomcat ==
Same as in case of [[Commercial_Certificates#1._Generate_a_CSR_for_tomcat|Generate a CSR for tomcat]].
Same as in case of [[4.x_Commercial_Certificates_Guide#1._Generate_a_CSR_for_tomcat|Generate a CSR for tomcat]].
== Submit the CSR to CACert certificate authority ==
== Submit the CSR to CACert certificate authority ==
Line 283: Line 287:
== You can use the same CRT for other services. ==
== You can use the same CRT for other services. ==
See [[Commercial_Certificates#D._Extract_the_private_key_for_use_with_postfix.2C_perdition.2C_ldap|step 2D]] of the general certificate process.
See [[4.x_Commercial_Certificates_Guide#D._Extract_the_private_key_for_use_with_postfix.2C_perdition.2C_ldap|step 2D]] of the general certificate process.
= PEM Format Commercial SSL Cert Install Procedure=
= PEM Format Commercial SSL Cert Install Procedure=
Line 409: Line 412:
=Commercial SSL Certificates for non java services=
See [[Commercial_Certificates#D._Extract_the_private_key_for_use_with_postfix.2C_perdition.2C_ldap|step 2D]] of the general certificate process.
=GlobalSign SSL References=
#[http://www.globalsign.com/ GlobalSign Homepage]
#[http://www.globalsign.com/support/ssl.php GlobalSign SSL Support Page] - search for tomcat installation.
=QuickSSL References=
=QuickSSL References=
Line 417: Line 422:
#[http://www.quickssl.com/support/knowledge_base/index.asp QuickSSL Knowledgebase] - search for tomcat installation.
#[http://www.quickssl.com/support/knowledge_base/index.asp QuickSSL Knowledgebase] - search for tomcat installation.
=GoDaddy Instructions=
(You will be prompted for passwords. Use zimbra for all passwords)
'''1. Create keystore:'''
su - zimbra
keytool -genkey -alias tomcat -keyalg RSA -keystore /opt/zimbra/ssl/ssl/commercial.keystore
'''2. Create CSR (you are creating the commercial.csr file):'''
keytool -certreq -keyalg RSA -alias tomcat -file /opt/zimbra/ssl/ssl/commercial.csr -keystore /opt/zimbra/ssl/ssl/commercial.keystore
Note: when it asks you for your first and last name use the common name of your server. For example, if you will ultimately use zimbra.company.com as the URL then that is your common name.
'''3. Open the contents of the commercial.csr file and copy and paste into GoDaddy's CSR submission form.'''
'''4. Receive digital cert from GoDaddy as a zip file.''' Unzip and copy the cert and intermediate cert to a directory on the server. For simplicity, complete the commands below from that directory.
'''5. Import intermediate and root certs from GoDaddy.''' The intermediate cert is included in the zip file. The root cert is not. Download the root cert for GoDaddy from: https://certificates.starfieldtech.com/Repository.go
To import root cert: keytool -import -alias root -keystore /opt/zimbra/ssl/ssl/commercial.keystore -trustcacerts -file valicert_class2_root.crt
Note: As of 4/2/2007 - Using RHEL 4 with all updates the Root cert was not needed.
U'''pdate: 4/2/2007''' - Go to this page: https://certificates.godaddy.com/Repository.go Download the '''gd_cross_intermediate.crt.''' You should have received gd_intermediate.crt as part of the zip file from GoDaddy. You will need the cross and the intermediate certificates in order to create the "chain".
'''To import intermediate cert''': keytool -import -alias intermed -keystore /opt/zimbra/ssl/ssl/commercial.keystore -trustcacerts -file gd_intermediate.crt
'''To import the cross cert:''' keytool -import -alias cross -keystore /opt/zimbra/ssl/ssl/commercial.keystore -trustcacerts -file gd_cross_intermediate.crt
'''6. Import digital cert into keystore:'''
keytool -import -alias tomcat -keystore /opt/zimbra/ssl/ssl/commercial.keystore -trustcacerts -file [FileNameofCert] -storepass zimbra
'''7. Copy the keystore to zimbra Tomcat keystore:'''
cp /opt/zimbra/ssl/ssl/commercial.keystore /opt/zimbra/tomcat/conf/keystore
'''8. Tomcat restart'''
'''9. To turn on HTTPS you must use the zmtlsctl https to allow http and https logins OR zmtlsctl mixed to force https logins but all other traffic will be http.'''
'''10. To use your certificate for other services, follow the instructions above under "You can use the same CRT for other services". '''
=GeoTrust Instructions=
For all those having difficulties with the instructions at the top of this page maybe this will help.  This was done for Zimbra 4.5 using some of the included scripts for certificate handling.
'''1.  ***Backup Your Keystore***'''
    sudo zimbra cp /opt/zimbra/tomcat/conf/keystore /opt/zimbra/tomcat/conf/keystore.bak
'''2.  su zimbra'''
'''3.  Create a new file or a copy of bin/zmcreatecert to make this script''' (personalize the bits between *** to match your settings)
source /opt/zimbra/bin/zmshutil || exit 1
if [ -f "${JAVA_HOME}/lib/security/cacerts" ]; then
rm -rf ${BASE}/newCA
mkdir -p ${BASE}/ca
mkdir -p ${BASE}/newCA/newcerts
touch ${BASE}/newCA/index.txt
mkdir -p ${BASE}/cert
mkdir -p ${BASE}/server
mkdir -p ${TCONF}
hostname=***Set this to your full domain name mail.domain.com***
if [ "x$1" != "x" ]; then
createConf() {
        for alt in $*; do
                if [ "x$ALTNAMES" = "x" ]; then
                        ALTNAMES="subjectAltName = DNS:${hostname},DNS:${alt}"
        cat ${CONF}/zmssl.cnf.in | sed -e "s/@@HOSTNAME@@/$hostname/" \
                -e "s/@@ALTNAMES@@/$ALTNAMES/" > ${BASE}/zmssl.cnf
createKeyStore() {
        echo "** Creating keystore"
        rm -f ${TCONF}/keystore
        keytool -validity 730 -genkey -dname "CN=$hostname, OU=**Set to Your Org Unit***, O=***Set to Your Company***, L=**Set to Your City***, S=***Set to Your State***, C=US" \
                -alias tomcat -keyalg RSA -keysize 1024 -keystore ${TCONF}/keystore \
                -storetype JKS -storepass zimbra -keypass zimbra
createCertReq() {
        echo "** Creating server cert request"
        openssl req -new -nodes -out ${BASE}/server/server.csr \
                -keyout ${BASE}/server/server.key -newkey rsa:1024 \
                -config ${BASE}/zmssl.cnf -batch
        keytool -certreq -keyalg RSA -alias tomcat -file \
                ${BASE}/server/tomcat.csr -keystore \
                ${TCONF}/keystore -storepass zimbra
        cp ${BASE}/server/tomcat.csr /tmp/tomcat.csr.$$
        cat /tmp/tomcat.csr.$$ | sed -e \
                > ${BASE}/server/tomcat.csr
signCertReq() {
        echo "** Signing cert request"
        openssl ca -out ${BASE}/server/server.crt -notext \
                -config ${BASE}/zmssl.cnf -in ${BASE}/server/server.csr \
                -keyfile ${BASE}/ca/ca.key -cert ${BASE}/ca/ca.pem -batch
        cp ${BASE}/server/server.crt ${CONF}/slapd.crt
        cp ${BASE}/server/server.key ${CONF}/slapd.key
        cp ${BASE}/server/server.crt ${CONF}/perdition.pem
        cp ${BASE}/server/server.key ${CONF}/perdition.key
        mkdir -p ${CONF}/ca
        cp ${BASE}/ca/ca.key ${CONF}/ca/ca.key
        cp ${BASE}/ca/ca.pem ${CONF}/ca/ca.pem
createConf $@
chmod -R 700 ${B}
'''4.  Run this newly created script'''
Essentially this script will generate and sign a new certificate for slapd and perdition and also generate a signing request for tomcat.  The signing request for tomcat will be in /opt/zimbra/ssl/ssl/server/tomcat.csr  Take the contents of the csr and submit them to your certificate authority (Geotrust in this case).  You will then receive by email a certificate.
'''5.  Take the certificate from the authority and paste it into /opt/zimbra/ssl/ssl/server/tomcat.pem'''
'''6.  Run the command openssl x509 -in tomcat.pem -inform PEM -outform DER -out tomcat.crt'''
This will convert the certificate into binary DER format which keytool likes.
You will also need to download the root ca from Geotrust this can be found at
          - for a TrueBusinessID certificate download the Equifax Secure Certificate Authority file that is in DER encoded X.509 format
          - for a QuickSSL certificate download the Equifax Secure Global eBusiness CA-1 file that is in the DER encoded X.509 format
'''7.  Put whichever file you needed in /opt/zimbra/ssl/ssl/geotrust.crt'''
'''8.  Run the command as root keytool -import -alias geotrustca -keystore /opt/zimbra/java/jre/lib/security/cacerts -file /opt/zimbra/ssl/ssl/geotrust.crt -storepass changeit''' (If this says the chain already exists, don't overwrite the existing one, and skip to the next step)
'''9.  Run the command as root keytool -delete -alias my_ca -keystore /opt/zimbra/java/jre/lib/security/cacerts -storepass changeit'''
'''10. Run the command as zimbra keytool -import -alias tomcat -keystore /opt/zimbra/tomcat/conf/keystore -trustcacerts -file /opt/zimbra/ssl/ssl/server/tomcat.crt -storepass zimbra'''
'''11. Run the command as zimbra /opt/zibmra/bin/tomcat restart''' (or restart zimbra with zmcontrol stop && zmcontrol start)
'''12. If all went as planned you should now be able to access https://your.mailsite.com'''
'''13. If you recieve page cannot be displayed copy the /opt/zimbra/tomcat/conf/keystore.bak to /opt/zimbra/tomcat/conf/keystore and restart tomcat again.'''
'''14. If you did break tomcat and did not follow the backup keystore in step 1.  It is possible to get up and running again by doing the following.'''
          - su zimbra
          - /opt/zimbra/bin/zmcreateca
          - /opt/zimbra/bin/zmcreatecert
          - /opt/zimbra/bin/zmcertinstall
'''15. Test bin/zmprov to make sure it works without giving a untrusted certificate error.  If it doesn't, as root run the following''' (when prompted for a password use '''changeit''')
      /opt/zimbra/java/bin/keytool -import -alias tomcat -keystore /opt/zimbra/java/jre/lib/security/cacerts -file /opt/zimbra/ssl/ssl/server/tomcat.crt
*Note:  All the the scripts above were taken directly from the bin/zmcreatecert and bin/zmcertinstall scripts will a little modification.
=GeoTrust 5.x Notes=
*As Root:
'''1). move all the files in /opt/zimbra/ssl/zimbra/commercial'''
        cd /opt/zimbra/ssl/zimbra/commercial/
        tar -czvf /tmp/ssl.commercial.tar.gz *
        rm -rf *
'''2. generate a new csr , please edit this line for your company details'''
        /opt/zimbra/bin/zmcertmgr createcsr comm -new "/C=US/ST=TX/L=Somewhere/O=Company, Inc./OU=ChangeMe, Inc./CN=mail.CHANGEME.zxy"
'''3.) get it signed'''
        Place SSL order and paste in the contents of commercial.csr
        Put the certificate into commercial.crt using cat or vi
'''4. put your CA in place ( For GeoTrust QuickSSL, QuickSSL Premium, True BusinessID and Wildcard  http://www.geocerts.com/support/roots.php )'''
        wget https://www.geotrust.com/resources/root_certificates/certificates/Equifax_Secure_Certificate_Authority.cer
        mv Equifax_Secure_Certificate_Authority.cer commercial_ca.crt
'''5. verify that the cert and key match'''
        /opt/zimbra/bin/zmcertmgr verifycrt comm commercial.key commercial.crt
should return
** Verifying commercial.crt against commercial.key
Certificate (commercial.crt) and private key (commercial.key) match.
Valid Certificate: commercial.crt: OK
'''6. deploy the cert'''
        /opt/zimbra/bin/zmcertmgr deploycrt comm commercial.crt
'''7. restart the webserver
        su - zimbra
        zmmailboxdctl restart
*It's also very handy to have a copy of the comments for zmcertmgr around in a side window.
=Mac OSX Note=
=Mac OSX Note=
Line 678: Line 441:
= Alternate Commercial SSL Cert HOWTO =
This HOWTO includes installation of a commercial SSL cert that also requires an intermediate CA cert.
* [[Commercial Certificates/Alternate Commercial SSL Cert HOWTO | Alternate Commercial SSL Cert HOWTO]]
=Relevant Documents=
=Relevant Documents=
Line 687: Line 448:
[[Category: SSL/TLS]]
[[Category: SSL/TLS]]
[[Category: Certificates]]
[[Category: Certificates]]
[[Category: ZCS 4.5]]

Latest revision as of 19:31, 25 March 2015

Admin Article

Article Information

This article applies to the following ZCS versions.

ZCS 4.5 Article ZCS 4.5

FOR 5.x servers, please do not use this page

General Commercial SSL Certificate Procedure (Please read and understand this first)

  • Self-signed certificate directions can be found here: SSL_Certificate_Problems
  • Please read all instructions and pay attention to specific 4.5(and prior) vs 5.0 sections & notes.
  • DO NOT USE THIS DOCUMENT FOR ZCS Versions 5.0.0_GA and ABOVE. Use the Certificate wizard in the Admin Console of your installation to generate a commercial CSR.

Using a pre-existing certificate from another server

If you already have an "apache style" PEM or DER format certificate for this server hostname, and want to re-use it, this forum thread has been condensed to the PEM format certificate conversion section below.

Getting a certificate for MTA

If you are installing a commcercial certificate for the MTA and or LDAP, you can simply
acquire a certificate for postfix in "PEM" format and save the signed cert and the key
in /opt/zimbra/conf directory and reload postfix 

Generate a certificate signing request (CSR) for tomcat

Create a commercial keystore


  1. The file we call "commercial.keystore" in this guide is just an intermediate working file, which you will eventually copy into place in /opt/zimbra/tomcat/conf/keystore (until ZCS 4.5.x) or /opt/zimbra/jetty/etc/keystore (starting in ZCS 5.0).
  2. Make sure you create a new file; if you are updating certificates and there is already a commercial.keystore, rename it or use a different name for these steps.
  3. Make sure you save the new commercial.keystore file; you will import the server certificate and any intermediate certificates from the CA into this keystore before deploying it for tomcat or jetty.

For 4.x

# su - zimbra
# keytool -genkey -alias tomcat -keyalg RSA -keystore /opt/zimbra/ssl/ssl/commercial.keystore

Use "zimbra" for the keystore password, and the hostname of your server for the first/last name.

Note: In versions of ZCS up to and including 4.5.6, you must use "zimbra" for the keystore password; starting with ZCS 4.5.7, this will be configurable through the zmlocalconfig parameter tomcat_keystore_password. If your organization is Acme Co in San Francisco CA, with the zimbra mail server mailhost.domain.com, the process will look like this:

   zimbra@mailhost$ keytool -genkey -alias tomcat -keyalg RSA -keystore /opt/zimbra/ssl/ssl/commercial.keystore
   Enter keystore password:  zimbra
   What is your first and last name?
     [Unknown]:  mailhost.domain.com
   What is the name of your organizational unit?
     [Unknown]:  Acme Co
   What is the name of your organization?
     [Unknown]:  Acme Co
   What is the name of your City or Locality?
     [Unknown]:  San Francisco
   What is the name of your State or Province?
     [Unknown]:  California
   What is the two-letter country code for this unit?
     [Unknown]: US
   Is CN=mailhost.domain.com, OU=Acme Co, O=Acme Co, L=San Francisco, ST=CA, C=US correct?
     [no]:  y

   Enter key password for <tomcat>
          (RETURN if same as keystore password):

Starting with ZCS version 4.5.6, we are generating a random password for the keystore. This password can be retrieved via "zmlocalconfig -s -m nokey tomcat_keystore_password. If you specify zimbra as the password for the commercial.keystore, tomcat won't start due to keystore password mismatch.

The workaround is to:
  1. retrieve the current keystore password and use it when creating the commercial.keystore OR
  2. use zimbra as the password and when you are done with the process, change the keystore password to be zimbra
# zmlocalconfig -e tomcat_keystore_password=zimbra
# tomcat restart

I recommend using option 2. since it is less hassel.

Create the certificate request file

Remember the password is "zimbra"; this should all be on one line:

# keytool -certreq -keyalg RSA -alias tomcat -file /opt/zimbra/ssl/ssl/commercial.csr -keystore /opt/zimbra/ssl/ssl/commercial.keystore

The result is in the file commercial.csr:

cat /opt/zimbra/ssl/ssl/commercial.csr


Acquire and install the certificate

Note: Be sure to save your existing certs; see the "Back up existing certificates" section of the Cert Issues page.

Submit the CSR to the certificate authority of choice

To turn that into a certificate, you'll need to paste it into the web form of your favorite certificate vendor (verisign.com, godaddy, etc.) and they'll take some money from you and return a certificate as a file we'll call my.crt.

Import the cert into the commercial keystore

Note: Make sure to make a copy of the "commercial.keystore" after generating the CSR. If you end up damaging this file without backing it up, it will be necessary to create a new keystore and submit a new CSR to the Certificate Authority.

For 4.x

# keytool -import -alias tomcat -keystore /opt/zimbra/ssl/ssl/commercial.keystore -trustcacerts -file my.crt -storepass zimbra

Note: If this returns the error "keytool error: java.security.cert.CertificateParsingException: invalid DER-encoded certificate data", you may need to convert the certificate from PEM-encoded to DER-encoded. Keep in mind that default encoding for OpenSSL is PEM (ie. a OpenSSL produced signed cert will produce error above upon import).

If the signed certificate is successfully installed, the command will return "Certificate reply was installed in keystore".

If you have intermediate certs (Example: DigiCertCA.crt) install them as well.

  1. keytool -import -alias intermediate_crt_name -keystore /opt/zimbra/ssl/ssl/commercial.keystore -trustcacerts -file intermediate.crt -storepass zimbra

Copy the commercial keystore over the zimbra mailbox keystore

Note: This will overwrite the keystore currently in place.'

for 4.x

# cp /opt/zimbra/ssl/ssl/commercial.keystore /opt/zimbra/tomcat/conf/keystore
# tomcat restart

Extract the private key for use with postfix, perdition, ldap

The certificate install process so far only applies to the Zimbra services handled by tomcat or jetty (https, ssl pop, ssl imap). In order to use the certificate for other Zimbra network services (postfix/smtp, imapproxy, etc), you'll need get your cert and key in standard .pem format If you only have a java keystore file, you'll have to follow steps 1 and 2, otherwise you can skip to step 3. There are four steps: 1. Export the private key from the keystore, 2. Decrypt the private key, 3. Append any intermediate certs, 4. Copy the certificate and key files into place. Those with a Zimbra Support contract may contact support to handle steps 1 and 2.

1. In this case you have to get the key from /opt/zimbra/ssl/ssl/commercial.keystore (this can be a bit complicated.) More complete instructions at Mark Foster's page, or here is an abbreviated version that will work on most UN*Xes:

wget http://mark.foster.cc/pub/java/ExportPriv.java
javac ExportPriv.java
java ExportPriv /opt/zimbra/ssl/ssl/commercial.keystore tomcat zimbra > my.key

If you are using one of the latest 4.5.x builds, they use JDK 1.6 and ExportPriv.java will not compile because of sun.misc.BASE64Encoder; After you download ExportPriv.java, but before running javac, do the following extra steps:

Create a ExportPriv.patch file with this code:

--- ExportPriv.java 2005-03-26 12:34:13.000000000 -0500
+++ ExportPriv.java.new 2008-01-12 01:20:44.000000000 -0500
@@ -1,8 +1,8 @@
 // How to export the private key from keystore?
 // Does keytool not have an option to do so?
 // This example use the "testkeys" file that comes with JSSE 1.0.3
+// Alexey Zilber: Ported to work with Base64Coder: http://www.source-code.biz/snippets/java/2.htm

-import sun.misc.BASE64Encoder;
 import java.security.cert.Certificate;
 import java.security.*;
 import java.io.File;
@@ -10,9 +10,6 @@

 class ExportPriv {
     public static void main(String args[]) throws Exception{
-   for (int i = 0; i < args.length; i++) {
-           System.out.println(i + ": "+ args[i]);
-       }
        if (args.length < 2) {
            //Yes I know this sucks (the password is visible to other users via ps
            // but this was a quick-n-dirty fix to export from a keystore to pkcs12
@@ -29,8 +26,6 @@
    KeyStore ks = KeyStore.getInstance("JKS");

    char[] passPhrase = pass.toCharArray();
-   BASE64Encoder myB64 = new BASE64Encoder();

    File certificateFile = new File(fileName);
    ks.load(new FileInputStream(certificateFile), passPhrase);
@@ -38,9 +33,8 @@
    KeyPair kp = getPrivateKey(ks, aliasName, passPhrase);

    PrivateKey privKey = kp.getPrivate();

-   String b64 = myB64.encode(privKey.getEncoded());
+   char[] b64 = Base64Coder.encode(privKey.getEncoded());

    System.out.println("-----BEGIN PRIVATE KEY-----");
@@ -73,5 +67,3 @@



Download Christian d'Heureuse's Base64Coder.java, and do the following:

wget http://www.source-code.biz/snippets/java/Base64Coder.java.txt -O 'Base64Coder.java'
patch < ExportPriv.patch

Then proceed as per the instructions.

2. Decrypt the private key.

openssl rsa -in my.key -out my.key.dec

3. Append any intermediate certificates to your the certificate file.

If you have a certificate that requires an intermediate certificate or certificates, append the intermediate certificate(s) to the end of my.crt. Otherwise the certificate chain will be incomplete. You may need to download these certs from the CA; GoDaddy, for example, sends two intermediate crt's in a zip file (gd_cross_intermediate.crt and gd_intermediate.crt). If you have two intermediate certificates ca_int1.crt and ca_int2.crt from the CA, add them to the cert as follows.

keytool -export -alias tomcat -keystore /opt/zimbra/ssl/ssl/commercial.keystore -file exported.crt

openssl x509 -out exported-pem.crt -outform pem -text -in exported.crt -inform der

cat exported-pem.crt ca_int1.crt ca_int2.crt >> my.crt

4. Install your key and crt for other apps.

cp my.crt /opt/zimbra/conf
cp my.key.dec /opt/zimbra/conf/my.key
cd /opt/zimbra/conf
chmod 444 my.crt
chmod 400 my.key
chown zimbra:zimbra my.crt
chown zimbra:zimbra my.key
ln -s my.crt smtpd.crt
ln -s my.key smtpd.key
ln -s my.crt slapd.crt
ln -s my.key slapd.key
ln -s my.crt perdition.pem 
ln -s my.key perdition.key
#for 5.x add links for nginx too
ln -s my.crt nginx.crt
ln -s my.key nginx.key

Note: You'll need to restart any services that use the certificates in order for the new certificate to be used.

CACert SSL Certificate Procedure

For those who would like to use CACert signed certificate for their Zimbra.

Add CACert's Root CA certificates

Remove the self signed CA.

keytool -delete -alias my_ca -keystore /opt/zimbra/java/jre/lib/security/cacerts -storepass changeit

Download CACert's Root CAs from Class 1 PKI Key and Class 3 PKI Key and save them to a file.

Import these two CAs into Java.

keytool -import -alias cacertclass1ca -keystore /opt/zimbra/java/jre/lib/security/cacerts -import -trustcacerts -file root.crt
keytool -import -alias cacertclass3ca -keystore /opt/zimbra/java/jre/lib/security/cacerts -import -trustcacerts -file class3.crt

Generate a CSR for tomcat

Same as in case of Generate a CSR for tomcat.

Submit the CSR to CACert certificate authority

  • Login to CACert.
  • Select "Server Certificates" or "Org Server Certs" New
  • Paste the content of your /opt/zimbra/ssl/ssl/commercial.csr and Submit it.
  • Copy the content between the begin and end marker (including them)

into a file my.crt.

Install your new CRT

Note: You may want to save your existing certs; see the "Back up existing certificates" section of the Cert Issues page.

Import the new CRT

Import the new CRT into the commercial keystore.

keytool -import -alias tomcat -keystore /opt/zimbra/ssl/ssl/commercial.keystore -trustcacerts -file my.crt -storepass zimbra

Copy it into tomcat.

cp /opt/zimbra/ssl/ssl/commercial.keystore /opt/zimbra/tomcat/conf/keystore

The same if you are renewing a CACert certificate (and probably any certificate). Just import it, DO NOT DELETE the old one from the keystore as it will delete the root CA reference also. By just importing the renewed certificate the root CA in the chain is preserved. To see the certificates in your chain do:

keytool -list -v -alias tomcat -keystore /opt/zimbra/tomcat/conf/keystore -storepass zimbra

You can use the same CRT for other services.

See step 2D of the general certificate process.

PEM Format Commercial SSL Cert Install Procedure

Delete Existing Certs

delete the self generated CA from java's list of trusted CA certs

keytool -delete -alias my_ca -keystore /opt/zimbra/java/jre/lib/security/cacerts -storepass changeit

for 4.x, delete the private key for tomcat

keytool -delete -alias tomcat -keystore /opt/zimbra/tomcat/conf/keystore -storepass zimbra
for 4.5.9, the storepass is hidden in zmlocalconfig -s tomcat_truststore_password

for 5.0rc1, delete jetty's private key

you'll have to look up the keystore's password

zmlocalconfig -s mailboxd_keystore_password
keytool -delete -alias jetty -keystore /opt/zimbra/jetty/etc/keystore -storepass YOURPASSHERE

Add the CA certificate to java's list of trusted certs

keytool -import -alias YOUR_CA_NAME -keystore /opt/zimbra/java/jre/lib/security/cacerts -storepass changeit -trustcacerts -file /PATH/TO/YOUR/CACERT

Commercial SSL Certificates for Tomcat / Java

If you receive your certificates in the more or less standard PEM format, you need to do the following:

Convert your certificate and key files to a combined PKCS12 format certificate:

openssl pkcs12 -inkey /path/to/file.key -in /path/to/file.crt -export -out file.pkcs12

When prompted for an export password, use zimbra.

Convert the PKCS12 certificate to a Java Keystore format (JKS):

for 4.x

Download the Jetty package, as it contains a useful class that can convert PKCS12 format certificates to JKS format certificates. Version 5.1.x of Jetty is recommended.

java -classpath $JETTY_HOME/lib/org.mortbay.jetty.jar org.mortbay.util.PKCS12Import file.pkcs12 keystore

Note: make sure to set to the keystore password to whatever Zimbra expects ("zimbra")

for 5.0rc1 jetty is already installed

java -cp /opt/zimbra/jetty/lib/jetty-6.1.5.jar org.mortbay.jetty.security.PKCS12Import yourfile.pkcs12 keystore

Note: set the password to the value stored in zmlocalconfig -s mailboxd_keystore_password

Identify the alias that was imported (may be "1" or it might be something else, depends on how the pkcs12 file was made)

keytool -keystore keystore -list 

Clone the new keystore certificate stored under youralias to the alias "tomcat":

for 4.x

keytool -keystore keystore -keyclone -alias youralias -dest tomcat

for 5.0rc1

keytool -keystore keystore -keyclone -alias youralias -dest jetty

keep the password you selected above.

Delete the certificate stored under youralias:

keytool -delete -alias youralias -keystore keystore

Alternative: Use this source to directly create a keystore without having to download jetty. This only works for 4.x

- Tip: when creating file.pkcs12, set "zimbra" as password.

- First, replace "file.pkcs12" in source code with the name of the certificate you created and compile by executing:

export CLASSPATH=/opt/zimbra/java/lib/tools.jar:.
/opt/zimbra/java/bin/javac AddCertToKeystore.java

- Second, execute newly created .class file to generate new keystore (called keystore-new)

/opt/zimbra/java/bin/java AddCertToKeystore

- Copy new keystore-new to /opt/zimbra/tomcat/conf/keystore. I suggest to backup your old keystore before.

- Restart tomcat.

Source code for AddCertToKeystore.java

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.Key;
import java.security.KeyStore;
import java.security.Security;
import java.security.cert.Certificate;
import java.util.Enumeration;

class AddCertToKeystore {
    public static void main(String[] args) throws Exception {
        if (args.length < 2) {
            System.err.println("Usage: AddCertToKeystore <pkcs12_file> <keystore_file>");
        String pkcs12_file = args[0];
        String keystore_file = args[1];

        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

        // Load the pfx file containing Certificate + Private Key
        KeyStore temp = KeyStore.getInstance("PKCS12", "SunJSSE");
        temp.load(new FileInputStream(pkcs12_file), "zimbra".toCharArray());

        // Create a new Keystore
        KeyStore keyStore = KeyStore.getInstance("JKS");
        keyStore.load(null, "zimbra".toCharArray());

        // Find the alias name of the certificate from the pfx file
        Enumeration aliasNames = temp.aliases();
        String alias = (String) aliasNames.nextElement();

        // Get the certificate chain from .pfx
        Certificate c[] = temp.getCertificateChain(alias);
        Key key = temp.getKey(alias, "zimbra".toCharArray());

        // Store the Private Key + Certificate Chain in the Keystore
        keyStore.setKeyEntry("tomcat", key, "zimbra".toCharArray(), c);

        // Create the Keystore
        keyStore.store(new FileOutputStream(keystore_file), "zimbra".toCharArray());

GlobalSign SSL References

  1. GlobalSign Homepage
  2. GlobalSign SSL Support Page - search for tomcat installation.

QuickSSL References

  1. QuickSSL Homepage
  2. QuickSSL Knowledgebase - search for tomcat installation.

Mac OSX Note

In order for any changes on this page to go into the appropriate cacerts keystore, the following two paths must be exchanged in order to add the cert to the java trustedcerts...

Linux standard (from doc): /opt/zimbra/java/jre/lib/security/cacerts

OS X location: /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/security/cacerts

For example, the command to add a GoDaddy root cert from Valicert to the cacerts keystore would look like:

keytool -import -alias tomcat -keystore /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/security/cacerts -trustcacerts -file /opt/zimbra/ssl/<your ssl root_keys path>/valicert_class2_root.crt -storepass changeit

Relevant Documents

  1. Apache Jakarta Tomcat documentation
Jump to: navigation, search