Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create self-signed certificate in Java which will be automatically trusted by web browsers?

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.

like image 364
Corehpf Avatar asked Aug 19 '09 17:08

Corehpf


People also ask

Will browser trust self-signed certificate?

Accessing a local HTTPS website using self-signed certificates in Live would show a warning page by the browser indicating the website is not secure. This is because the self-signed certificate used by the local website is not recognized or installed on the real device used in Live.


2 Answers

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?

like image 69
RichieHindle Avatar answered Sep 30 '22 02:09

RichieHindle


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.

like image 32
Brian Kelly Avatar answered Sep 30 '22 01:09

Brian Kelly