2012-11-26 4 views
4

SSL WebServices Apache Tomcat에 연결하는 중에 Java SE 클라이언트가 제대로 연결되지만 Android 클라이언트가 연결을 원하지 않습니다. 1. "보안 요구 사항이 충족되지 않았습니다 - 메시지에 보안 헤더가 없습니다", 2. Java.lang.RuntimeException : java.lang.RuntimeException : 오류 : 0407006A : rsa 루틴 : RSA_padding_check_PKCS1_type_1 : 블록 유형이 다음 오류 중 하나를 표시합니다. . 01 (SHA-1) "연결하려면, 나는 다음과 같은 코드를 설명합니다 (PKCS # 12) blablabla.pfx하는 blablabla.jks의 서버에 의해Android kSOAP2 SSL 자체 서명 인증서 "보안 요구 사항을 충족하지 못함 - 메시지에 보안 헤더가 없습니다"

private SSLSocketFactory getSSLSocketFactory() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException { 
    KeyStore trusted = KeyStore.getInstance("PKCS12"); 
    InputStream in = activity.getResources().openRawResource(R.raw.client_keystore); 
    try { 
     trusted.load(in, "blablabla".toCharArray()); 
    } catch (CertificateException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } finally { 
     try { 
      in.close(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
    } 

    TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509"); 
    tmf.init(trusted); 
    SSLContext context = SSLContext.getInstance("SSLv3"); 
    context.init(null, tmf.getTrustManagers(), null); 
    return context.getSocketFactory(); 
} 

public String SendRecieveMessage(String xmlData, String nameXML, String methodName, String methodAction) { 

    HttpsTransportSE httpTransport = new KeepAliveHttpsTransportSE("hostname", 8443, "/blablabla/blablabla?wsdl", 1000); 
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
    SoapObject request = new SoapObject(activity.getResources().getString(R.string.SOAP_NAMESPACE), methodName); // set 
    // request 
    Log.e("Sending SOAP", xmlData); 
    String base64 = base64Coder.encodeString(xmlData); 
    request.addProperty(nameXML, base64); 
    envelope.setOutputSoapObject(request); // prepare request 
    try { 
     ((HttpsServiceConnectionSE) httpTransport.getServiceConnection()).setSSLSocketFactory(getSSLSocketFactory()); 
    } catch (KeyManagementException e1) { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
    } catch (KeyStoreException e1) { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
    } catch (NoSuchAlgorithmException e1) { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
    } catch (IOException e1) { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
    } 
    SoapPrimitive result = null; 
    try { 
     httpTransport.call(methodAction, envelope); 
     result = (SoapPrimitive) envelope.getResponse(); // get 
     if (result != null) { 
      base64 = base64Coder.decodeString(result.toString()); 
     } else { 
      base64 = null; 
     } 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     Log.e("ERROR", "SOAPSendRecieve: " + e.getMessage()); 
     base64 = null; 
    } catch (XmlPullParserException e) { 
     // TODO Auto-generated catch block 
     Log.e("ERROR", "SOAPSendRecieve: " + e.getMessage()); 
     base64 = null; 
    } catch (IllegalArgumentException e) { 
     Log.e("ERROR", "SOAPSendRecieve: " + e.getMessage()); 
     base64 = null; 
     } 
    } finally { 
     request = null; 
     result = null; 
    } 
    return base64; 
} 

변환을, 나는이 개 프로그램을 사용하여 시도" 키 저장소 예 plorer "와"Portecle "을 사용하고 형식"BKS "를 시도해 보았습니다. SSL kSOAP2는 공식 웹 사이트의 Example에 설명되어 있으며 문제가 될 수 있습니다. 잘못되었거나 클라이언트가 문제 일 수 있습니다. 서버 설정에서?

예 요청 및 응답 덤프 : 문제가 해결 된 enter image description here

+0

전체 스택 추적을 게시 할 수 있습니까? PKCS # 12 파일에있는 인증서가 올바르게 파싱되지 않을 수 있습니다. –

+0

게시 된 덤프 kSOAP2, 로그 Tomcat Catalina에서 클라이언트가 연결을 시도하고 있지만 웹 서비스의 로그에서 덤프로 인해 비어있는 것으로 확인되어 Tomcat이 클라이언트를 이해하지 못해서 이유를 이해할 수 없습니다. –

+0

SSL 연결을 설정할 수 없으면 요청으로 인해 웹 서버에 연결되지 않습니다. 당신은 클라이언트 (안드로이드) 전체 스택 추적을 보여줄 수 있습니까? –

답변

0

, 서버가, 그로 "사용자"및 "암호", SOAP 메시지이다 보호 보안 헤더를 요구 라이브러리 WSIT를 배포 한 I 이 매개 변수를 지정하지 않은 경우, 메시지 헤더에 설명 된 내용을 연결하지 않은 서버가 도움을 주셔서 감사합니다.

관련 문제