2015-02-03 2 views
1

내 앱 및 서버에 대한 상호 인증을 만들고 싶습니다. 다음 단계를 따르십시오 :상호 인증 Android 및 Tomcat

1) 인증서를 생성하십시오. 및 서버 키 저장소 (tomcat.keystore)

2) certf를 만듭니다. 클라이언트 용

3) 클라이언트 인증서를 가져옵니다. 서버 키 저장소

4)로 안드로이드에 대한의 활동 키 스토어 (smartssl.bks)

5) 가져 오기 certf을 만듭니다.

안드로이드 스토어에 서버와 클라이언트가 지금은 함께 Tomcat을 구성합니다

<Connector SSLEnabled="true" clientAuth="true" 
      keystoreFile="/home/antonio/Documenti/keystore/tomcat.keystore" 
      keystorePass="pass" maxThreads="150" port="8443" scheme="https" 
      secure="true" sslProtocol="TLS" 
      truststoreFile="/home/antonio/Documenti/keystore/tomcat.keystore" 
      truststorePass="pass" /> 

그리고 안드로이드 응용 프로그램에서 내가 그런 발리 프레임 워크 사용이 설정으로

InputStream keyStore = getResources().openRawResource(R.raw.smartssl); 

       // Usually getting the request queue shall be in singleton like in {@see Act_SimpleRequest} 
       // Current approach is used just for brevity 
       RequestQueue queue = Volley 
         .newRequestQueue(Act_SsSslHttpClient.this, 
             new ExtHttpClientStack(new SslHttpClient(keyStore, "pass", 443))); 

       StringRequest myReq = new StringRequest(Method.GET, 
                 "https://192.168.1.4:8443/REST/app/generali/getA", 
                 createMyReqSuccessListener(), 
                 createMyReqErrorListener()){ 
       @Override 
       public Map<String, String> getHeaders() throws AuthFailureError { 
        return createBasicAuthHeader("user", "strongpassword"); 
       }}; 

       queue.add(myReq); 
      } 
     }); 

합니다. 나는이 오류가 :

no peer certificate 

내가이와 Tomcat 구성을 변경하려고하는 경우 :

clientAuth="false" 

작품을, 그래서 문제가 파일의 활동에? 또는 어디에?

답변

0

앱에 Keystore와 Truststore를 BKS로 넣어서 해결합니다.

여기에 자체 인증서를 만들 수있는 가이드가 :

Create a self certificate for client and server

을 그리고 여기에 발리와 상호 인증을위한 클래스 예제가있다 :

Example class for Mutual auth TLS/SSL

Class SSLSocket

+0

안녕하세요 @antonio, 제가 튜토리얼 위에 시도했지만 성공할 수 없습니다. 당신이 샘플 안드로이드 프로젝트를 제공 해주십시오. 내 안드로이드 애플 리케이션은 다음 예외를 throw합니다 :'java.security.GeneralSecurityException : 키 스토어 스트림을 읽는데 문제가 있습니다. ' –

+0

@ IB의 키 스토어가 BKS2 일 수도 있습니다. keyexplorer로 keystore를 creify하고 bks를 선택하십시오. –