A fairly basic HOWTO / cookbook that will attempt to cover:
NOTE: Use decent passwords or all of this is a waste!!
Configure OpenSSL openssl.cnf
export SSLDIR=<where your certificates live>/demoCA
mkdir ${SSLDIR}
mkdir ${SSLDIR}/certs
mkdir ${SSLDIR}/crl
mkdir ${SSLDIR}/newcerts
mkdir ${SSLDIR}/private
touch ${SSLDIR}/index.txt
echo "0001" > ${SSLDIR}/serial
echo "0001" > ${SSLDIR}/crlnumber
Note: This does not seem to work correctly under cygwin rxvt. Use the default cygwin terminal window!
0.a Generate a key for the CA certificate - this should have a larger keysize as it secures all other certificates
openssl genrsa -des3 -out ./demoCA/private/cakey.pem 2048
0.b Convert the key you generated into a self-signed CA certificate..
The cakey.pem file should reside in the demoCA/private/ directory when it is being used. It must be kept very safe! So perhaps store it on removable media while it is not needed.
@param req Specifies that this produces a Certificate REQuest
@param -new Specifies that this is a NEW request (not a renewal etc...)
@param -x509 Specifies that this produces an x509 Certificate
@param -key <key filename> The file that contains the Key for this request
@returns -out <ca certificate filename> The filename of the CA Certificate
openssl req -new -x509 -key ./demoCA/private/cakey.pem -out ./demoCA/cacert.pem
This is the first step to creating any Certificate (be it CA, Client, Server, etc...). It is used to generate the certificate request. You must generate a separate key for each certificate!
@param genrsa Specifies that this should generate an RSA Key
@param -des3 Specifies that this key needs a password
@param <keysize> Specifies how long the key should be 1024 is probably a minimum these days
@returns -out <certificate key filename> The filename of the keyfile
openssl genrsa -des3 -out certificate-key.pem 1024
This is a request for a certificate this would be sent to Verisign etc... or used by your own internal CA to generate the certificate
@param req Specifies that this produces a Certificate REQuest
@param -new Specifies that this is a NEW request (not a renewal etc...)
@param -key <key filename> The file that contains the Key for this request
@returns -out <certificate request filename> The filename of the request
openssl req -new -key certificate-key.pem -out certificate-req.pem
This builds the certificate from the request using a specific CA. You can set days of validity or a start and end date here too. Otherwise it takes the defaults from the config file
@param x509 Specifies that this produces an x509 Certificate
@param ca Specifies that this is a CA action
@param -req Specifies that this is from a request
@param -in <Request filename> The certificate request used to create this certificate
@returns -out <certificate filename> The filename of the Certificate
openssl ca -in certificate-req.pem -out certificate.pem -notext
openssl ca -extensions v3_ca -in certificate-req.pem -out sub-ca-cert.pem -notext
@returns x509 Specifies that this produces an x509 certificate
@param -in <Request filename> The certificate request used to create this certificate
@returns -outform der Specifes that this produces x509 der format file
@returns -out <certificate filename> The filename of the Certificate
openssl x509 -in certificate.pem -outform der -out certificate.der
This procduces a PKCS12 format file that contains both the certificate and the key. This type of file is suitable for installation into the client's browser (eg Microsoft Internet Explorer or Mozilla Firefox etc...)
@param -in <certificate filename> The input client certificate file
@param -inkey <certificate key filename> The input client key file used to generate the orignal certificate request (@see Generate Key)
@param -certfile <CA certificate filename> The CA Certificate to attach as the certificate chain
@param -name "<A nice name for the certificate>" The name displayed in Internet Explorer or other browsers
@returns -out <certificate p12 format output filename>
openssl pkcs12 -export -in certificate.pem -inkey certificate-key.pem \
-certfile ./demoCA/cacert.pem -out client.p12 -name "Name of Certificate"
This command creates the initial (empty) CRL for your CA, valid for 90 days. Once this CRL expires, you can simply create a new one.
openssl ca -gencrl -crldays 90 -out ./demoCA/crlFile.pem
To revoke an actual certificate:
openssl ca -revoke certificate.pem
You now need to publish this information in a CRL file:
openssl ca -gencrl -crldays 90 -out ./demoCA/crlFile.pem
You can view the list of revoked certificates in a CRL using the following command:
openssl crl -in ./demoCA/crlFile.pem -text -noout
This section describes how to build key and trust stores (ie you do not need to keep a copy of each client certificate in the server).
A trust store contains trusted certificates. These can be individual certificates of specific people, or more likely and more useful CA certificates of Authorities that are trusted. ANY client certificates signed by CA certificates that are in the trust store will be trusted. So make sure that there are no other certificates in the trust store (eg Verisign CA) unless you want people with certificates issued by those other CAs to also be able to access your application.
Import the PEM format CA certificate into the server truststore:
keytool -import -v -keystore server.truststore -storepass 123456 -file ca-cert.pem
Then copy the server.truststore file to the jboss conf directory
cp server.truststore ${jboss.server.home.dir}/conf/
The key store is where the server keeps its keys (certificates that it will present to the client). The client (browser) will need to trust this certificate explicitly or the CA that signed it so as not to display a warning message about "untrusted certificate". So in this case you can either
A) import a server certificate in PEM format (as decribed in 2.2) into the keystore. The client will then need to trust that certificate explicitly - which IMHO is not neat, esp if the server certificate expires at some time.
B) import the CA signed server certificate with the certificate chain PKCS12 format into the keystore. The client then only needs to trust the CA certificate - which if you have sent them their own PKCS12 certificate - will happen automatically at their end (or at least as part of the installation)
Import server certificate (in PKCS12 format) into the server keystore:
Unfortunately keytool cannot handle PKCS12 format certificates so a work around is as follows:
To do this a java class taken from Jetty is used. Download Jetty (if required) and locate the PKCS12Import.java file. This needs to be compiled and then run (from within the jetty-5.1.11RC0/classes/org/mortbay/util directory):
java -classpath ../../../../lib/org.mortbay.jetty.jar org.mortbay.util.PKCS12Import server.p12 server.keystore
Enter input keystore passphrase: <this is the passphrase of the p12 file>
Enter output keystore passphrase: <this is the passphrase of the keystore>
The next two steps are not required but neater if you need to look inside the keystore later. The PKCS12Import class puts the host certificate and key into the keystore with an alias of 1. To rename the alias the following steps are required :
keytool -keyclone -keystore server.keystore -alias 1 -dest <host_name>
keytool -delete -keystore server.keystore -alias 1
To check the content of your keystore
keytool -list -v -keystore server.keystore
This should contain the entry of type keyEntry, which is a chain of certificates.
Then copy the server.keystore file to the conf directory as well
cp server.keystore ${jboss.server.home.dir}/conf/
This section describes how to use the key and trust stores created in Section 2.
Where only the CA certificates is stored in the server.truststore (ie you do not need to keep a copy of each client certificate in the server) you need to be able to use Certifcate Revocation Lists (CRLs) see further down for how to implement this. Basically this translates to:
In jboss-3.2.4+ the tomcat-5.0.x container has its configuration in the jbossweb-tomcat50.sar/server.xml descriptor.
Edit jbossweb-tomcat50.sar/server.xml and uncomment the following section and update the keystoreFile and truststoreFile sections to match the ones you have created:
<!-- SSL/TLS Connector configuration using the admin devl guide keystore-->
<Connector port="8443" address="${jboss.bind.address}"
maxThreads="100" strategy="ms" maxHttpHeaderSize="8192" emptySessionPath="true"
scheme="https" secure="true" clientAuth="true"
sslProtocol = "TLS"
keystoreFile="${jboss.server.home.dir}/conf/server.keystore"
keystorePass="123456"
truststoreFile="${jboss.server.home.dir}/conf/server.truststore"
truststorePass="123456" />
For CRL to work in JBoss/Tomcat the ${jboss.server.home.dir}/deploy/jbossweb-tomcat55.sar/tomcat-util.jar must contain the classes:
To arrange this it is necessary to do some recompilation with a JDK1.5 target. If you do not update this jar CRL will NOT work! A copy of the recompiled jar containing the required libraries is here on an as is basis, (I have no idea if this affects other functions, security concerns, performance etc... so use at own risk, don't run with scisors blah blah).
Create a CRL (see earlier on this page) and copy the CRL into the conf directory so that the server can access it.
cp crlFile.pem ${jboss.server.home.dir}/conf/server.crlFile
Edit jbossweb-tomcat50.sar/server.xml and include the extra line:
<!-- SSL/TLS Connector configuration using the admin devl guide keystore-->
<Connector port="8443" address="${jboss.bind.address}"
maxThreads="100" strategy="ms" maxHttpHeaderSize="8192" emptySessionPath="true"
scheme="https" secure="true" clientAuth="true"
sslProtocol = "TLS"
keystoreFile="${jboss.server.home.dir}/conf/server.keystore"
keystorePass="123456"
truststoreFile="${jboss.server.home.dir}/conf/server.truststore"
truststorePass="123456"
crlFile="${jboss.server.home.dir}/conf/server.crlFile" />
Restart your JBoss server and attempt to reach it at for example: https://localhost:8443/jmx-console/index.jsp
NOTES:
Some articles imply that the format for the crlFile is independent of the keystore format. This does not appear to be the case.
Broken Example: Here you have the keystore type set as PKCS12 even though the CRL is a PEM format file (and hence not PKCS12 format). PKCS12 contains the private key as well as the certificate and public key - which is not applicable for the CRL file so this seems to be why it's getting confused.
<Connector port="8443" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="true" sslProtocol="TLS"
crlFile="/ca/crl/crl.pem"
keystoreType="PKCS12" keystoreFile="/ca/ssl/idp.p12"
keystorePass="123456" />
The only way I know of making it work is to remove the keystoreType field and building the keystores as described earlier on this page.
There is a good description of the various issues at play here: http://wiki.mozilla.org/PSM:CertPrompt
Note this is not an extensive configuration guide (as these are more prevalent on the web), just some notes about either of these two browsers.
In general it is fairly easy to install certificates (both client and CA) in both of these browsers. Most users should be able to accomplish this with a reasonable set of instructions. Getting the browser to present the right certificate can be more challenging.
SSL sends a list of CA certificates that are acceptable for Client Authentication. Most HTTP servers build this list automatically whenever that server has CA Certificates which are configured to validate user certificates. Browsers sometimes use this information to present a certificate to the Server.
Some notes:
Some notes:
http://www.openssl.org/
http://www.gagravarr.org/writing/openssl-certs/ca.shtml
http://www.drh-consultancy.demon.co.uk/pkcs12usg.html
http://churchillobjects.com/c/11201g.html
http://wiki.jboss.org/wiki/Wiki.jsp?page=SSLSetup
http://wiki.mozilla.org/PSM:CertPrompt
http://mail-archives.apache.org/mod_mbox/jakarta-tomcat-user/200408.mbox/%[email protected]%3E