When i try to make a request to an API, through java to the ip or the resorce https://172.17.14.16, throws me the following error: "No subject alternative names matching IP address 172.17.14.16 found", but if I deactivate the host verification it works for me, my question is if there is no problem doing that, I don't know if It can generate security problems so that a third party can exploit it
URL urlWs = new URL(url);
SSLContext sc = SSLContext.getInstance("TLSv1.2");
sc.init(null, null, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
conexion = (HttpURLConnection) urlWs.openConnection();
this.metodo = "POST";
this.timeout = timeout;
init(header)
i do this,and it gives me this problem: "Exception in thread "main" javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names matching IP address 172.17.14.16 found
",, but when i try this way it works for me:
URL urlWs = new URL(url);
SSLContext sc = SSLContext.getInstance("TLSv1.2");
sc.init(null, null, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
// Realizar la verificación del nombre de host aquí
// Puedes comparar el nombre del host con el certificado del servidor
// Devuelve true si es válido, o false si no lo es
return false;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
conexion = (HttpURLConnection) urlWs.openConnection();
this.metodo = "POST";
this.timeout = timeout;