Download HyperSQL User Guide - HyperSQL Database Engine (HSQLDB) 2.2

Transcript
HyperSQL Network Listeners
(Servers)
the server certificate was purchased, then you are all set; if somebody "signed their own" certificate by self-signing
or using a private ca certificate, then you need to set up trust).
First, you need to obtain the cert (only the "public" part of it). Since this cert is passed to all clients, you could obtain
it by writing a Java client that dumps it to file, or perhaps by using openssl s_client. Since in most cases, if you want
to trust a non-commercial cert, you probably have access to the server keystore, I'll show an example of how to get
what you need from the server-side JKS keystore.
You may already have an X509 cert for your server. If you have a server keystore, then you can generate a X509
cert like this.
Example 13.1. Exporting certificate from the server's keystore
keytool -export -keystore server.store -alias existing_alias -file server.cer
In this example, server.cer is the X509 certificate that you need for the next step.
Now, you need to add this cert to one of the system trust keystores or to a keystore of your own. See the
Customizing Stores section in JSSERefGuide.html [http://java.sun.com/javase/6/docs/technotes/guides/security/jsse/
JSSERefGuide.html#CustomizingStores] to see where your system trust keystores are. You can put private keystores
anywhere you want to. The following command will add the cert to an existing keystore, or create a new keystore if
client.store doesn't exist.
Example 13.2. Adding a certificate to the client keystore
keytool -import -trustcacerts -keystore trust.store -alias new_alias -file server.cer
If you are making a new keystore, you probably want to start with a copy of your system default keystore which you
can find somewhere under your JAVA_HOME directory (typically jre/lib/security/cacerts for a JDK, but
I forget exactly where it is for a JRE).
Unless your OS can't stop other people from writing to your files, you probably do not want to set a password on
the trust keystore.
If you added the cert to a system trust store, then you are finished. Otherwise you will need to specify your
custom trust keystore to your client program. The generic way to set the trust keystore is to set the system property
javax.net.ssl.trustStore every time that you run your client program. For example
Example 13.3. Specifying your own trust store to a JDBC client
java -Djavax.net.ssl.trustStore=/home/blaine/trust.store -jar /path/to/hsqldb.jar dest-urlid
This example runs the program SqlTool . SqlTool has built-in TLS support however, so, for SqlTool you can set
truststore on a per-urlid basis in the SqlTool configuration file.
Note: The hostname in your database URL must match the Common Name of the server's certificate exactly.
That means that if a site certificate is admc.com, you can not use jdbc:hsqldb:hsqls://localhost or
jdbc:hsqldb:hsqls://www.admc.com:1100 to connect to it.
If you want more details on anything, see JSSERefGuide.html on Sun's site [http://java.sun.com/javase/6/
docs/technotes/guides/security/jsse/JSSERefGuide.html], or in the subdirectory docs/guide/security/jsse
of your Java SE docs.
Server-Side (Listener-Side)
Get yourself a
JKS keystore containing a private key . Then set properties server.tls,
system.javax.net.ssl.keyStore and system.javax.net.ssl.keyStorePassword in your
248