Reputation: 11
we are doing a connection with an IIS Server with HttpsUrlConnection in Android Studio project.
These are my statements:
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setConnectTimeout(15000);
HashMap<String, String> paramss = new HashMap<String, String>();
paramss.put("grant_type", "password");
paramss.put("username", prefer.getString("ws_sq_user",""));
paramss.put("password", prefer.getString("ws_sq_pwd",""));
Set set = paramss.entrySet();
Iterator i = set.iterator();
StringBuilder postData = new StringBuilder();
for (Map.Entry<String, String> param : paramss.entrySet()) {
if (postData.length() != 0) {
postData.append('&');
}
postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
postData.append('=');
postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
}
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
connection.setRequestMethod("POST");
connection.setDoInput(true);
try {
connection.getOutputStream().write(postDataBytes);
}
catch (Exception ex)
{
}
I receive the error javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. If I use the same statements with a Ngrok system I didn't have the same problem; on the site there is an SHA256RSA certificate. I downloaded the pfx and cer file but the problem is the same.
Upvotes: 1
Views: 13