Hi guy, 

I am connecting to an WCF Service via SSL + Certificates. 
After the first query I always get a 403 Response. 
The strange thing is that the first call works just fine. 
Do you have any ideas what could be the problem? Should I use the 
HttpClient class instead?
I would appreciate your help. 



Here is some code: 

     if (clientCert.length() > 1) {

            int iResponseCode = 0;
            String sErrorMessage = "";

            if (keyManager == null) {
                keyManager = KeyChainKeyManager.fromAliasAdvanced(context,
                        clientCert);
            }

            try {
                if (sslContext == null) {
                    sslContext = SSLContext.getInstance("TLS");
                }

            } catch (NoSuchAlgorithmException e) {
                Log.e(TAG, "message", e);
                e.printStackTrace();
            }
            try {
                sslContext.init(new KeyManager[]{keyManager},
                        getCustomTrustManagers(), new SecureRandom());

            } catch (KeyManagementException e) {
                Log.e(TAG, "message", e);
                e.printStackTrace();
            }

            HttpsURLConnection urlConnection = 
getHttpsURLConnection(sslContext);
            urlConnection.setHostnameVerifier(new NullVerifier());

            try {
                iResponseCode = urlConnection.getResponseCode();

                // better check it first
                if (iResponseCode / 100 != 2) {      // 
HttpsURLConnection.HTTP_OK
                    // Error
  
                }

                if (!bError) {
                    result = readResult(urlConnection);
                }
            } catch (IOException e) {
                Log.e(TAG, sErrorMessage);
                e.printStackTrace();
            } finally {
                urlConnection.disconnect();
            }

best regards,

jens

-- 
You received this message because you are subscribed to the Google Groups 
"Android Security Discussions" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/android-security-discuss/-/SiAGON3sUS4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/android-security-discuss?hl=en.

Reply via email to