Android的kSOAP2 SSL自签名证书"安全要求没有得到满足 - 在消息&QUOT无安全性头; [英] Android kSOAP2 SSL self-signed certificates "Security Requirements not met - No Security header in message"

查看:331
本文介绍了Android的kSOAP2 SSL自签名证书"安全要求没有得到满足 - 在消息&QUOT无安全性头;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有连接到SSL Web服务的Apache Tomcat的一个问题,Java SE的客户端连接正常,但Android客户端不想要连接,并显示以下错误之一:不符合1.安全要求 - 无安全头球消息,2了java.lang.RuntimeException:了java.lang.RuntimeException:错误:0407006A:RSA套路:RSA_padding_check_PKCS1_type_1:块类型不是01(SHA-1)
。 要连接,我描述了以下code:

there is a problem connecting to the SSL WebServices Apache Tomcat, Java SE client connects fine, but the Android client does not want to connect and displays one of the following errors: 1. "Security Requirements not met - No Security header in message", 2. "Java.lang.RuntimeException: java.lang.RuntimeException: error: 0407006A: rsa routines: RSA_padding_check_PKCS1_type_1: block type is not 01 (SHA-1) . "To connect, I describe the following code:

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),我用两个方案的尝试:密钥库资源管理器和Portecle,并且还试图格式BKS,同样的结果,SSL kSOAP2例中描述的官方网站上,在可能是什么问题,那是因为不正确或客户端可能会在服务器设置有问题的错误呢?

Converts by a server in blablabla.jks to blablabla.pfx (PKCS # 12), I tried using two programs: "KeyStore Explorer" and "Portecle", and also tried the format "BKS", the same result, SSL kSOAP2 described in Example on the official website, in what could be the problem, it is a mistake because of incorrectly or client may be a problem in the server settings?

实例的请求和响应转储:

Example request and response dump:

推荐答案

该问题得到解决,服务器部署库WSIT,其要求保护的安全标,那就是用户和密码,一个SOAP消息,如我没有具体说明这些参数,在邮件标题给人说明我没有连接到服务器,谢谢大家的帮助。

The problem was resolved, the server was deployed library WSIT, which demanded protection Security Header, that is "User" and "Password", a SOAP message, as I did not specify these parameters, the server I did not connect giving described in the message header thank you all for the help.

这篇关于Android的kSOAP2 SSL自签名证书"安全要求没有得到满足 - 在消息&QUOT无安全性头;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆