Two-way ssl fails in android

Highlighted
Regular Visitor

Two-way ssl fails in android

I tested every thing in SoapUI and "Helloworld" is ok, I want ti implement it in android but I couldn't so far. How can I use two way ssl in android? Do you have very basic sample code just for Httpconnection? your sample java codes are not readable at least for me!

 

 public void postData(Context context) {

        String url = "https://sandbox.api.visa.com";
        String obj = "";
        JSONObject object = new JSONObject();
        try {
            object = new JSONObject(obj);
        } catch (JSONException err) {
            Log.e("Error", err.toString());
        }
        // Enter the correct url for your api service site
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url, object,
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        Log.e("Response", response.toString());
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e("errrororor", error.toString());

            }
        }) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                final Map<String, String> headers = new HashMap<>();
                headers.put("Authorization", "{"+Base64.getEncoder().encodeToString((user + ":" + pass).getBytes())+"}");//put your token here
                headers.put("Accept","application/json,application/octet-stream");
                return headers;
            }
        };
        RequestQueue requestQueue = Volley.newRequestQueue(context);
        requestQueue.add(jsonObjectRequest);
    }

this is code I used to connect to sanbox, I need to add my key to this code I could't because the sapmle code provided in: https://developer.visa.com/pages/working-with-visa-apis/two-way-ssl 

doesn't work anymore because of change in new versions of android after 23. 

1 REPLY 1
Highlighted
Visa Dev Moderator

Re: Two-way ssl fails in android

Hey @ehsan,

 

Can you please let us know the API product name that your question is related to?

 



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

Thanks,
Diana