I try to connect to a server with a self-signed certificate. I use this code to accept all certificates.
public class CertificateAcceptor {
public void
ALLOW_ALL is not the correct answer. You should set up your certificate with the correct name by using keytool with the ext extension:
keytool -genkeypair \
-keystore keystore.jks \
-dname "CN=OLEKSIYS-W3T, OU=Sun Java System Application Server, O=Sun Microsystems, L=Santa Clara, ST=California, C=US" \
-keypass changeit \
-storepass changeit \
-keyalg RSA \
-keysize 2048 \
-alias default \
-ext SAN=DNS:localhost,IP:127.0.0.1 \
-validity 9999
See http://tersesystems.com/2014/03/23/fixing-hostname-verification/ for more details.