2014-04-30 6 views
1

나는 다음과 같은 코드가 있습니다안드로이드 2.3 오류 : 아니 CA 인증서

HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); 
    conn.setConnectTimeout(60000); //set timeout to 60 seconds  
    conn.connect(); 

    InputStream input = new BufferedInputStream(url.openStream()); 
    OutputStream output = new FileOutputStream(filePath); 
    byte data[] = new byte[1024]; 
    long total = 0; 

    while ((count = input.read(data)) != -1) { 
     output.write(data, 0, count); 
    } 

    output.close(); 
    input.close(); 

내가 파일을 다운로드하기위한이 코드를 가지고있다.

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Not a CA certificate 

내가 안드로이드 4.3에서 테스트하고 2.3에 normaly하지만 작동 : 나는 그것을 executin하고 때 나는 내가 어떤 페이지에서 찾을 수없는이 IOException이 오류가 발생합니다. 어떤 생각이 잘못 될 수 있습니다. 브라우저와 iOS에서도 잘 작동합니다. 나는 또한 http://www.sslshopper.com/의 인증서를 확인하고 everythink는 잘 작동합니다.

+0

이것은 알려진 (구 안드로이드) 오류 : http://stackoverflow.com/questions/21183043/sslhandshakeexception-trust-anchor-for-certification-path-not- found-android-http http://stackoverflow.com/questions/21306336/android-2-3-x-javax-net-ssl-sslhandshakeexception-java-security-cert-certpathva – shkschneider

+0

나는 이것을 발견했지만, 나는 원하지 않는다. .crt 파일을 추가하십시오. 주위에 다른 산책 거리가 있습니까? – ButterBeast

답변

0

나는 완벽하게 작동하는 해결책을 발견했습니다. 대신 URLConection를 사용하는 내가 사용 HttpClient를 :

HttpClient httpclient = new DefaultHttpClient(); 
HttpGet httpget = new HttpGet(url.toString()); 
HttpResponse response = httpclient.execute(httpget); 
HttpEntity entity = response.getEntity();