I don’t know if this is an issue with Firefox (3.0.10), Ubuntu (9.04), Apache2 or the default apache config file, but when trying to surf to a SSL-encrypted page on a default installation of Apache on Ubuntu, with a default self-signed certificate, Firefox (also a completely default installation, this is on a new system with nothing on it yet) just gave me a sec_error_ca_cert_invalid popup, without any possibility to add an exception. The “Or you can add an exception…” link I’m used to simply did not appear. Surfing into the site from a windows computer worked nicely.
After a (long) while I realized that whatever the problem was, it only appeared when surfing to https://localhost/ . If i surfed to https://computername/ , I got the expected behavior.
Weird.
I finally got my answer. I can’t tell you how many retries, reinstalls of apache – openssl and the like I went through and could not get rid of the error (which was the same as yours above). I got no option to add an exception either in Firefox. Just an error (sec_invalid). I’m on Vista and I found the solution after your direction being to comment out in the /etc/hosts file the entry for ::1 localhost. Which then when I would go back would allow the regular default https://localhost to perform as expected and request you to add an exception. Much thanks!
Another workaround is to set network.dns.disableIPv6
to true (using about:config).