Overview
I have a Linux box at home, running Apache 2.2, that I use to archive pictures. I use an application called Gallery as a front end to organize and view the photos. I'm using a Java application called Gallery Remote to upload pictures to the server. I've also added SSL encryption so that the username and password, to access the site, are not sent in the clear.
Problem and Solution
The problem was that Gallery Remote wasn't able to connect to the server. It seemed to be having problems with the SSL certificate I had on the web server. I was using a self-signed SSL certificate, so that was definitely possible. I checked out the SSL certificate and found that it was expired. I regenerated a new certificate using the instructions on the Apache Website. The relevant text is shown below.
How do I create a self-signed SSL Certificate for testing purposes?
- Make sure OpenSSL is installed and in your
PATH.
- Run the following command, to create
server.keyand
server.crtfiles:
$ openssl req -new -x509 -nodes -out server.crt
-keyout server.key
These can be used as follows in yourhttpd.conf
file:
SSLCertificateFile /path/to/this/server.crt
SSLCertificateKeyFile /path/to/this/server.key
- It is important that you are aware that this
server.keydoes not have any passphrase.
To add a passphrase to the key, you should run the following
command, and enter & verify the passphrase as requested.
$ openssl rsa -des3 -in server.key -out
server.key.new$ mv server.key.new server.key
Please backup theserver.keyfile, and the passphrase
you entered, in a secure location.
After restarting the webserver, I was still having problems with Gallery Remote. I then found out that Java has it's own repository of trusted SSL certificates. My SSL certificate was a self-signed certificate, so it definitely wasn't in the default SSL Certificate trust list. One method of adding the certificate is by going through the Java control panel. Another method is to add it through the command line. This was described on the Gallery Remote FAQ page. The relevant text is shown below.
Using HTTPSYou can use https:// URLs with Gallery Remote to connect to secured web sites. This functionality is only available on Java 1.4 and later. If the site you are attempting to connect to uses a server certificate that is not certified by a trusted certificate authority, Gallery Remote will be unable to connect. If this happens, you will need to add the site's certificate to the Java registry of trusted certificates:
For Windows:
- Go to the site with Internet Explorer
- Go to menu File>Properties
- In the Properties window, click Certificates
- On the Details tab, click Copy to File...
- In the wizard, select DER-encoded X.509 certificate and save it to a
file- Open a console window (cmd.exe)
- Type the following command-line:
keytool -import -trustcacerts -file path_to_cer_file
-keystore %JAVA_HOME%/jre/lib/security/cacerts -alias arbitrary_name
You'll be prompted for the store password, which by default ischangeit
I used that and it worked. It's interesting to note that Java uses it's own keystore and that there's a default password used if using the command line.
No comments:
Post a Comment