2013-02-21 7 views
1

자체 서명 인증서가있는 호스팅을 사용합니다. 따라서 내 도메인 https://www.marpel.cz/에서 인증서를 다운로드하고 http://portecle.sourceforge.net/을 사용하여 .bks 파일을 만들었습니다.자체 서명 인증서

https 연결을 설정하고 웹 서비스에서 데이터를 검색해야합니다. 나는 ksoap2 라이브러리를 사용한다. 나는 ksoap2 위키에 명시된 클래스 ConnectionWithSelfSignedCertificate을 복사하여 사용했습니다.

내가 키 스토어

MainActivity.java 
    // Get an instance of the Bouncy Castle KeyStore format 
    try { 
     this.keyStore = KeyStore.getInstance("BKS"); 
    } catch (KeyStoreException e1) { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
    } 
    // Get the raw resource, which contains the keystore with 
    // your trusted certificates (root and any intermediate certs) 
    InputStream in = this.getApplicationContext().getResources().openRawResource(R.raw.myCer); 
    try { 
     // Initialize the keystore with the provided trusted certificates 
     // Also provide the password of the keystore 
     this.keyStore.load(in, "myPass".toCharArray()); 
    } catch (Exception e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    }finally { 
     try { 
      in.close(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
    } 

    try { 
     this.sslSocketFactory = new ConnectionWithSelfSignedCertificate(this.keyStore).getSSLSocketFactory(); 
    } catch (Exception e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 

를 만드는 방법입니다 그리고 이것은 AsyncTask를

background task 
final HttpsTransportSE transportSE = new HttpsTransportSE(URL, PORT, SERVICE, TIMEOUT); 

    try { 
     ((HttpsServiceConnectionSE) transportSE.getServiceConnection()).setSSLSocketFactory(this.sslSocketFactory); 
    } catch (IOException e1) { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
    } 

내가 transportSE.call (SOAP_ACTION, 봉투)를 호출하는 경우에서 코드; IOException이 발생하고 호스트 이름 'www.marpel.cz'이 확인되지 않았습니다. 내가 뭘 잘못 했니?

ICS 4.1.2 장치가 있습니다.

답변

0

먼저 자체 서명 인증서를 사용합니까? 예,이 링크를 따라하는 경우

는 : android-webservices-via-ksoap2-https

당신이 만드는 HTTPS 연결을하고 인증서의 수용을위한 별도의 클래스가 필요합니다. 모든 것이 준비되면 transportSE으로 전화 할 수 있습니다.

0

첫 번째 게시물의 코드는 정상적으로 작동합니다. 자체 서명 인증서가 다른 도메인에 발행되었음을 확인했습니다. 나는 증명서를 고쳤고 모든 것이 잘 작동한다. 여기 https://www.marpel.cz:445/

고정 된 인증서 실행 마틴을 주셔서 감사합니다.