4

连接到 SSL WebServices Apache Tomcat 时出现问题,Java SE 客户端连接正常,但 Android 客户端不想连接并显示以下错误之一:1.“未满足安全要求 - 消息中没有安全标头”, 2. “Java.lang.RuntimeException: java.lang.RuntimeException: error: 0407006A: rsa routines: RSA_padding_check_PKCS1_type_1: block type is not 01 (SHA-1) . “要连接,我描述如下代码:

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;
}

由 blablabla.jks 中的服务器转换为 blablabla.pfx(PKCS #12),我尝试使用两个程序:“KeyStore Explorer”和“Portecle”,还尝试了“BKS”格式,结果相同,SSL kSOAP2 中描述官方网站上的例子,可能是什么问题,是因为错误或客户端可能是服务器设置有问题而导致的错误?

示例请求和响应转储: 在此处输入图像描述

4

1 回答 1

0

问题解决,服务器部署了库WSIT,需要保护Security Header,即“User”和“Password”,一个SOAP消息,由于我没有指定这些参数,服务器我没有连接给出的描述在邮件标题谢谢大家的帮助。

于 2012-11-28T20:10:00.513 回答