java.security.cert.CertificateException: No subject alternative names matching IP address xxx.xxx.xx…

  • Post author:
  • Post category:java


https与http不同的是,https加密,需要验证证书,而http不需要。

在连接的代码中加上:

static {
        disableSslVerification();
    }

    private static void disableSslVerification() {
        try
        {
            // Create a trust manager that does not validate certificate chains
            TrustManager[] trustAllCerts = new TrustManager[] {
   new X509TrustManager() {