Not sure what your issue is, but I'll note that I don't recommend
HttpClient as an alternative. It doesn't support SNI and other newer
TLS extensions and most likely never will.

-bri

On Mon, Jan 7, 2013 at 1:16 AM, Jens <[email protected]> wrote:
> 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.

-- 
You received this message because you are subscribed to the Google Groups 
"Android Security Discussions" group.
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