나는 많은 옵션을 시도했으며, 나는 미쳐 갈 것입니다. URL에 게시하려고 할 때마다 SSL 예외가 계속 발생합니다.Android HTTPS 요청
이것은 HttpWebRequest를 사용하는 C#의 꿈처럼 작동합니다. 내가 할
오류는 다음과 같습니다
Not trusted server certificate
java.security.cert.CertPathValidatorException: TrustAnchor for CertPath not found.
지금은 다음과 같은 방법을 시도하고있다,하지만, 모든 사용자 정의 SocketFactories을 시도했습니다. 도와주세요!
final String httpsURL = "https://...";
final DefaultHttpClient client = new DefaultHttpClient();
final HttpPost httppost = new HttpPost(httpsURL);
//authentication block:
final List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>();
nvps.add(new BasicNameValuePair("mail", username));
nvps.add(new BasicNameValuePair("password", password));
UrlEncodedFormEntity p_entity = null;
try {
p_entity = new UrlEncodedFormEntity(nvps, HTTP.UTF_8);
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
httppost.setEntity(p_entity);
//sending the request and retrieving the response:
HttpResponse response = null;
try {
response = client.execute(httppost, _context);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
HttpEntity responseEntity = response.getEntity();
//handling the response: responseEntity.getContent() is your InputStream
try {
final InputSource inputSource = new InputSource(responseEntity.getContent());
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
, 나는이 작품 같은 요청을하기 위해 자바 키 저장소에 인증서를 추가했다. – mikey
@mikey, 내가 통과 한 인증서를 찾는 방법은 무엇입니까? – Benny
나는 당신이 인증서를 건네 준다고 믿지 않습니다. 서버가 제공 한 인증서가 신뢰할 수 있는지 확인해야합니다. C# 및 HttpRequest는 java와 다른 인증서 저장소에 대한 https 요청의 유효성을 검사합니다. 이것은 좋은 리소스 인 것처럼 보입니다. http://blog.antoine.li/index.php/2010/10/android-trusting-ssl-certificates/ – mikey