How to access https website where “MD2withRSA is d

2019-07-19 18:59发布

问题:

I'm getting the following exception message: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: algorithm check failed: MD2withRSA is disabled

I understand that as of java 6 rel 17 support for MD2withRSA was disabled. Unfortunately I'm trying to connect to a site which is using outdated software and I don't have the power to update it. I've no intention of taking back my java version (currently java 6 rel 20) as I don't want the project restricted by this.

This means that I need to get round this issue client side. I'm using some code that I've been provided with but I assume it was written for an older version of java:

HttpsURLConnection huc = (HttpsURLConnection) new URL(URL + URL_LOGIN).openConnection();
huc.setDoOutput(true);
huc.setRequestMethod("POST");
huc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

OutputStream os = huc.getOutputStream(); // exception is thrown here

os.write(("password=" + webSitePassword + "&submit:login=Login&username=" + webSiteUsername).getBytes("UTF-8"));
os.flush();
os.close();
huc.connect();

Can anyone provide me with a work around which doesn't involve taking back my java version or updating the server?

回答1:

I've updated my java version to Java 6 Update 30 and I'm no longer getting the exception.

This blog indicates that this issue was fixed in Update 21.

Based on the posts I've been reading this issue affects Java 1.6 Updates 17 through to 20