Android SSL Sertifika Sorunu
-
Mürit ve müridelerim,
SSL olan bir sayfadan bir ses dosyası çekmeye calışıyorum ve şöyle bir hata alıyorum..
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Kodlarım şu şekildedir...
private ProgressDialog DailogDownloadCustomerWav; class DownloadFileFromURL extends AsyncTask<String, String, String> { /** * Dialog Gösterme * * */ @Override protected void onPreExecute() { super.onPreExecute(); DailogDownloadCustomerWav = new ProgressDialog(LoginActivity.this); DailogDownloadCustomerWav.setMessage("Kayıtlı ses dosyası indiriliyor. Lütfen bekleyiniz..."); DailogDownloadCustomerWav.setIndeterminate(false); DailogDownloadCustomerWav.setMax(100); DailogDownloadCustomerWav.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); DailogDownloadCustomerWav.setCancelable(true); DailogDownloadCustomerWav.show(); } /** * Arka planda Ses dosyasının indirime başlanması * */ @Override protected String doInBackground(String... f_url) { int count; try { // Sertifika getiriliyor CertificateFactory cf = CertificateFactory.getInstance("X.509"); InputStream caInput = new BufferedInputStream(new FileInputStream("load-der.crt")); Certificate ca; try { ca = cf.generateCertificate(caInput); System.out.println("ca=" + ((X509Certificate) ca).getSubjectDN()); } finally { caInput.close(); } String keyStoreType = KeyStore.getDefaultType(); KeyStore keyStore = KeyStore.getInstance(keyStoreType); keyStore.load(null, null); keyStore.setCertificateEntry("ca", ca); String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm(); TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm); tmf.init(keyStore); SSLContext context = SSLContext.getInstance("TLS"); context.init(null, tmf.getTrustManagers(), null); /*HttpsURLConnection urlConnection = (HttpsURLConnection)url.openConnection(); urlConnection.setSSLSocketFactory(context.getSocketFactory()); InputStream in = urlConnection.getInputStream(); copyInputStreamToOutputStream(in, System.out);*/ URL url = new URL("" + "https://MyWebSite.php?" + "AuthKey=xxxx&AudioID=xxx"); HttpsURLConnection conection =(HttpsURLConnection)url.openConnection(); Log.e("Information","Waiting for connect url"); conection.connect(); Log.e("Information","Connect Succsfull"); int lenghtOfFile = conection.getContentLength(); Log.e("Information","Audio Lenght -> "+lenghtOfFile); // 8k buffer ile okuyoruz. InputStream input = new BufferedInputStream(url.openStream(), 8192); Log.e("Bilgi","Sayi Gönsteriliyor"); Log.e("Bilgi",lenghtOfFile+" Sayi File"); Log.e("Bilgi","Sayi Gönsterildi"); // Output stream to write file OutputStream output = new FileOutputStream("/sdcard/SesKaydi.wav"); byte data[] = new byte[1024]; long total = 0; while ((count = input.read(data)) != -1) { total += count; publishProgress(""+(int)((total*100)/lenghtOfFile)); output.write(data, 0, count); } output.flush(); output.close(); input.close(); } catch (Exception e) { Log.e("Error: ", e.getMessage()); } return null; } protected void onProgressUpdate(String... progress) { // setting progress percentage DailogDownloadCustomerWav.setProgress(Integer.parseInt(progress[0])); } @Override protected void onPostExecute(String file_url) { DailogDownloadCustomerWav.cancel(); String path = "/sdcard/SesKaydi.wav"; MediaPlayer mPlayer; mPlayer = new MediaPlayer(); mPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mPlayer.setDataSource(path); mPlayer.prepare(); mPlayer.start(); } catch (Exception e) { Log.e("Bilgi",e.getMessage()); } } }
Androidin kendi sitesindeki işlemleri gerçekleştirmeme rağmen olmadı.. daha önce böyle birşey ile karşılaşan var mı acaba ?
-
Aşağıya düşmüş
-
Hocam anlamam ama birkaç gün önce hack ile ilgili uygulama yüklemiştim sniffer uygulamasıydı galiba.Uygulama sertifika yüklemeden çalışmıyordu kendisi otomatik yükledi.Sertifika kısmı var uygun olan sertifika olmadan belki izin vermiyordur veri çekmene=))
hata da sertifika yolu bulunamadı diyor
koray tarafından 25/Nis/17 11:12 tarihinde düzenlenmiştir -
Hocam bu sertifika ile o ayrı.
Senin dediğin JKS olarak geçiyor. Kendi sertifikan uygulama sertifikan. Kendin imzalıyorsun apk'yı fakat benim istediğim SSL Sertifikası..