JVM to ignore certificate name mismatch

妖精的绣舞 提交于 2019-12-06 07:53:39

This works for me in a client application of mine, perhaps this will also work for you if you are (or Spring is internally) using HttpsURLConnection anywhere.

HostnameVerifier hv = new HostnameVerifier() {
  public boolean verify(String urlHostName, SSLSession session) {
    log.warning(String.format("Warning: URL Host: '%s' does not equal '%s'", urlHostName, session.getPeerHost()));
    return true;
  }
};

HttpsURLConnection.setDefaultHostnameVerifier(hv);

Its hardly SSL best practice though. The best solution would be to use a certificate that matches the hostname.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!