Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KPCS12 and Ksoap2 #201

Open
GoogleCodeExporter opened this issue Feb 15, 2016 · 1 comment
Open

KPCS12 and Ksoap2 #201

GoogleCodeExporter opened this issue Feb 15, 2016 · 1 comment

Comments

@GoogleCodeExporter
Copy link


The certificate KPCS12 is compatible with Ksoap2? the following code does not 
work , returns the error:

IOException e:
SSL handshake aborted: ssl=0x7a69ed90: I/O error during system call, Connection 
reset by peer


Code:

private SSLSocketFactory getSSLSocketFactory() throws KeyStoreException, 
NoSuchAlgorithmException, KeyManagementException {

    KeyStore trusted = KeyStore.getInstance("PKCS12");

    AssetManager assetManager = getAssets();
    InputStream in = null;

    try {
        in = assetManager.open("certificate.p12");
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    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(SoapObject 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

    envelope.setOutputSoapObject(xmlData); 
    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(); 
    } catch (IOException e) {
        // TODO Auto-generated catch block
        Log.e("ERROR", "SOAPSendRecieve: " + e.getMessage());    // <!-------------------- Error exception this here
    } catch (XmlPullParserException e) {
        // TODO Auto-generated catch block
        Log.e("ERROR", "SOAPSendRecieve: " + e.getMessage());
    } catch (IllegalArgumentException e) {
        Log.e("ERROR", "SOAPSendRecieve: " + e.getMessage());
        }
    } finally {
        request = null;
        result = null;
    }
    return result;
}

Original issue reported on code.google.com by [email protected] on 4 Dec 2014 at 2:44

@GoogleCodeExporter
Copy link
Author

The project is migrating to github. If you believe this issue is still valid 
and should be tracked please file a new issue at 
https://github.com/simpligility/ksoap2-android/issues



Original comment by [email protected] on 7 Aug 2015 at 5:35

  • Changed state: AwaitingContribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant