问题
I am trying to use get request on site with REST API. However the link to acces it is an IP address and I am getting the No subject alternative names matching IP address error.
When I use the same exact link in browser, it works.
How can I solve this issue?
Below is my code:
public static void main(String[] args) {
System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "socksProxyHost", "xxx.xxx.xxx.xxx" );
System.getProperties().put( "socksProxyPort", "xxxx" );
URL requestLink = ismTicketManager.UrlEncode.convertToURLEscapingIllegalCharacters("https://xx.xx.xx.xx/e/528f5016-6fd9-403f-85e4-5a54bb2498b9/api/v1/problem/feed?relativeTime=30mins&Api-Token=xxxxx");
try {
HttpURLConnection targetConn = (HttpURLConnection)requestLink.openConnection();
targetConn.setRequestMethod("GET");
System.out.println(targetConn.getResponseCode());
} catch (Exception e) {
e.printStackTrace();
System.out.println("Connection failed");
}
static {
HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> hostname.equals("127.0.0.1"));
}
}
Now I am getting error:
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
The cacerts fiel list looks like this:
restapi, 25-Sep-2018, trustedCertEntry, Certificate fingerprint (SHA1): AB:6D:C6:2E:9F:B3:D9:48:1E:A9:84:AA:DD:03:64:1D:7C:08:42:CE
Thank you for your time.
来源:https://stackoverflow.com/questions/52496137/java-no-subject-alternative-names-matching-ip-address