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

(Unverified Commercial SSL Cert Install Procedure)
Line 157: Line 157:
= Unverified Commercial SSL Cert Install Procedure=
= PEM Format Commercial SSL Cert Install Procedure=
Line 167: Line 167:
==Add the CA certificate==
==Add the CA certificate==
:keytool -import -keystore /path/to/keystore -import -trustcacerts -file /path/to/cacert.cer
:keytool -import -keystore /path/to/keystore -import -trustcacerts -file /path/to/cacert.cer
=Commercial SSL Certificates for Tomcat / Java=
=Commercial SSL Certificates for Tomcat / Java=

Revision as of 17:59, 24 April 2006

Commercial SSL Certificate Procedure

1. Generate a CSR for tomcat

A. Create a commercial keystore

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

Use "zimbra" for the keystore password, and the name of your host for the first/last name. 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]:  CA
  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):  

B. 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


2. Acquire and install the certificate

Note: You may want to save your existing certs; see the page about Cert Issues

A. 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 foo.crt.

B. Import the cert into the commercial keystore

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

C. Copy the commercial keystore over the zimbra tomcat keystore

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

Voila! the commercial cert is installed for tomcat.

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 you new CRT

Note: You may want to save your existing certs (see the page about Cert Issues)

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

You can use the same CRT for other services.

In this case you have to get the key from /opt/zimbra/ssl/ssl/commercial.keystore (which is a bit complicated).

Use Andrew Morrow ExportPriv tool.

Download, compile & run ExportPriv crafted from Andrew Morrow's posting in http://forum.java.sun.com/thread.jsp?forum=2&thread=154587&message=449486. The key will be produced to STDOUT. I suggest you redirect > to exported.key

javac ExportPriv.java
java ExportPriv /opt/zimbra/ssl/ssl/commercial.keystore tomcat zimbra > exported-pkcs8.key

The private key is being exported as PKCS#8 PEM format. To get it into the RSA format that works with Apache, Postfix, OpenLDAP you can issue the following command:

openssl pkcs8 -inform PEM -nocrypt -in exported-pkcs8.key -out my.key

Alternate way to extract the private key would be purchase Keystore Explorer, which claims to support exporting private keys and keypairs. It exports the key pair to pkcs12 format. However this feature is not present in the evaluation version.

Install your key and crt for other apps.

cp my.crt my.key /opt/zimbra/conf
chmod 644 /opt/zimbra/conf/my.crt
chmod 600 /opt/zimbra/conf/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

Restart tomcat (or even better the whole Zimbra server).


PEM Format Commercial SSL Cert Install Procedure


Download the Jetty package, as it contains a useful class that can convert PKCS12 format certificates to JKS format certificates.

Delete Existing Certs

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

Add the CA certificate

keytool -import -keystore /path/to/keystore -import -trustcacerts -file /path/to/cacert.cer

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

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

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 (usually "zimbra")

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

keytool -keystore keystore -keyclone -alias 1 -dest tomcat

Delete the certificate stored under the "1" alias:

keytool -delete -alias 1 -keystore keystore

Commercial SSL Certificates for Postfix

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

Decrypt the certificate key:

openssl rsa -in file.key -out file.key.decrypted

Move the cert and decrypted key into place:

mv file.crt /opt/zimbra/conf/smtpd.crt
mv file.key.decrypted /opt/zimbra/conf/smtpd.key

QuickSSL References

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

GoDaddy Instructions

(You will be prompted for passwords. In this example all passwords are zimbra)

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

3. Open the contents of the commecial.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

To import intermediate cert: keytool -import -alias intermed -keystore /opt/zimbra/ssl/ssl/commercial.keystore -trustcacerts -file sf_issuing.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.

Jump to: navigation, search