학교의 wifi 로그인 시스템에 자동 로그인 프로그램을 만들려고합니다. 인증 URL (https://ccahack.bergen.org/auth/perfigo_validate.jsp)에 POST 요청을하고 일부 매개 변수를 제출해야합니다. HTTPS를 HTTP로 변경하고 POST 요청을하면 포럼의 로그인으로 리디렉션됩니다. 당신은 코멘트에 게시 된 예외를 바탕으로POST 요청 (HTTPS) 요청이 실패하는 이유는 무엇입니까?
이public boolean signIn() throws Exception{
//System.setProperty("http.agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.29 Safari/537.36");
String httpsURL = "https://ccahack.bergen.org/auth/perfigo_validate.jsp";
String username = "username";
String password = "password";
StringBuilder q = new StringBuilder();
q.append("reqFrom="+URLEncoder.encode("perfigo_simple_login.jsp","UTF-8"));
q.append("&uri="+ URLEncoder.encode("https://ccahack.bergen.org/","UTF-8"));
q.append("&cm=" + URLEncoder.encode("ws32vklm", "UTF-8"));
q.append("&userip="+URLEncoder.encode("IP_ADDRESS HERE","UTF-8"));
q.append("&os=" +URLEncoder.encode("MAC_OSX","UTF-8"));
q.append("&index="+URLEncoder.encode("4","UTF-8"));
q.append("&username="+URLEncoder.encode(username,"UTF-8"));
q.append("&password="+URLEncoder.encode(password,"UTF-8"));
q.append("&provider="+URLEncoder.encode("BCA","UTF-8"));
q.append("&login_submt="+URLEncoder.encode("Continue","UTF8"));
String query = q.toString();
URL myurl = new URL(httpsURL);
HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-length", String.valueOf(query.length()));
con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
con.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0;Windows98;DigExt)");
con.setDoOutput(true);
con.setDoInput(true);
DataOutputStream output = new DataOutputStream(con.getOutputStream());
//error here
output.writeBytes(query);
output.close();
DataInputStream input = new DataInputStream(con.getInputStream());
for(int c = input.read(); c != -1; c = input.read())
System.out.print((char)c);
input.close();
System.out.println("Resp Code:"+con.getResponseCode());
System.out.println("Resp Message:"+ con.getResponseMessage());
return false;
}
오류를 게시하면 도움이됩니다. –
javax.net.ssl.SSLHandshakeException : sun.security.validator.ValidatorException : PKIX path building failed : sun.security.provider.certpath.SunCertPathBuilderException : 요청한 대상에 대한 유효한 인증 경로를 찾을 수 없습니다. – parasm