views:

941

answers:

4

Hi,

I've generated a self-signed certificate for my Java app using keytool. However, when I go to the site in a browser it always pops up with a warning - saying this site does not own the certificate - is there a way to self-sign/doctor a certificate so I won't get these warnings in a browser? Both server and browser are located on the same host and I navigate to the site using "http://localhost/". I do not want to add an exception to the browser because I have tests which run on a big build farm so it is excessive to add an exception to all browsers on all build machines.

+11  A: 

No, you can't. You might as well ask "How can I make a fake certificate for hsbc.com?"

There are two ways to get a browser to accept a certificate:

  • Buy a certificate for a domain from a trusted authority (which means proving to that authority that you own that domain) and then use that domain as the name of your test servers
  • Install your signing certificate into the browsers, so that you effectively become a trusted authority for that browser.

Without touching the browsers, there's no other way to do it - how could there be, if the internet is to remain secure?

RichieHindle
+1 for applying clue stick vigorously :-)
Stephen C
-1 very unhelpful and unimaginative answer.
Corehpf
@Corehpf - do you want an imaginative answer or the truth? There is NO WAY to get browsers to accept self-signed certs or certs signed by a non-root CA cert ... apart from installing them or the CA cert in your browsers.
Stephen C
+1  A: 

Is the certificate you created for localhost or for test.textbox.com? If you create a certificate for the FQDN test.textbox.com, that's how you need to be reaching the server to not get those errors, as long as the certificate is properly signed. You can't generate a certificate for the FQDN and then use an IP or an alias (localhost) to access it without being warned that things aren't matching up properly. Or am I misunderstanding your problem?

MattC
Note: Obviously test.testbox.com is just an example I used for this.
MattC
He's doing self-signed certs (meaning they don't trace back to any of the well-known CAs), so by definition he can't have them automatically accepted. To have a cert accepted automatically by a browser, it has to trace back to a CA that the browser knows about.
Michael Kohne
Yes but the error complaining that the site does not own the certificate indicates that the hostname the certificate was created for and whatever he is using to access that site are two different things. He said he's using localhost and I'm betting the cert is for the actual hostname of the server. That will cause red flags in most browsers as a security issue.
MattC
+4  A: 

You could also setup a self-signed Certificate Authority (CA) using OpenSSL or possibly your Java tool. You can then use that CA to sign a number of server certs.

You are still going to need to manually trust your self-signed CA on all clients that access your test servers, but at least you only have to trust one root CA, rather than a bunch of individual self-signed server certs.

Another option is to check out CAcert.

Brian Kelly
RichieHindle is correct. This method will not get rid of the warnings in the browser.
eman
Good Answer Brian
sixtyfootersdude
+1  A: 

Make the certificate for "localhost" instead. It needs to match the hostname you have in the URL.

You will still be bothered as the certificate is not trusted, but that is another issue.

Thorbjørn Ravn Andersen