This doesn't seem to work (setting the hostnameverifier). I get a
ClassCastException on the line:
HttpsURLConnection uc = (HttpsURLConnection)
requestUrl.openConnection();
Here's the stacktrace:
10-22 22:54:11.110: ERROR/AndroidRuntime(192): Caused by:
java.lang.ClassCastException:
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection
10-22 22:54:11.110: ERROR/AndroidRuntime(192): at
com.google.gdata.client.http.HttpGDataRequest.getRequestConnection(HttpGDataRequest.java:
307)
10-22 22:54:11.110: ERROR/AndroidRuntime(192): at
com.google.gdata.client.http.HttpGDataRequest.<init>(HttpGDataRequest.java:
222)
10-22 22:54:11.110: ERROR/AndroidRuntime(192): at
com.google.gdata.client.http.GoogleGDataRequest.<init>(GoogleGDataRequest.java:
448)
10-22 22:54:11.110: ERROR/AndroidRuntime(192): at
com.google.gdata.client.http.GoogleGDataRequest
$Factory.getRequest(GoogleGDataRequest.java:78)
10-22 22:54:11.110: ERROR/AndroidRuntime(192): at
com.google.gdata.client.Service.createRequest(Service.java:510)
10-22 22:54:11.110: ERROR/AndroidRuntime(192): at
com.google.gdata.client.GoogleService.createRequest(GoogleService.java:
486)
10-22 22:54:11.110: ERROR/AndroidRuntime(192): at
com.google.gdata.client.Service.createFeedRequest(Service.java:890)
10-22 22:54:11.110: ERROR/AndroidRuntime(192): at
com.google.gdata.client.Service.getFeed(Service.java:726)
10-22 22:54:11.110: ERROR/AndroidRuntime(192): at
com.google.gdata.client.GoogleService.getFeed(GoogleService.java:583)
10-22 22:54:11.110: ERROR/AndroidRuntime(192): at
com.google.gdata.client.Service.getFeed(Service.java:746)
Of course without making it a HttpsURLConnection, we can't set the
hostname verifier. So it's a catch 22 situation.
Has anyone actually gotten this working?
On Sep 9, 11:34 pm, stunti <[EMAIL PROTECTED]> wrote:
> You need to modify the code of gdata.
> The certificates used by HttpURLConnection are not available to
> validate thehostnameduring a SSL connexion.
> A small workaround below.
> around line 332 in com.google.gdata.client.http.HttpGDataRequest
>
> You might also want to disable GZIP compression as it seems to messed
> up the content for theXMLparser.
> I don't know if it will be fized within the next release.
>
> HttpsURLConnection uc = (HttpsURLConnection)
> requestUrl.openConnection();
> uc.setHostnameVerifier( new X509HostnameVerifier(){
> @Override
> public boolean verify(String host, SSLSession session) {
> // TODO Auto-generated method stub
> return true;
> }
>
> @Override
> public void verify(String host, SSLSocket ssl) throws
> IOException {
> // TODO Auto-generated method stub
> }
>
> @Override
> public void verify(String host, X509Certificate cert)
> throws SSLException {
> // TODO Auto-generated method stub
> }
>
> @Override
> public void verify(String host, String[] cns, String[]
> subjectAlts)
> throws SSLException {
> // TODO Auto-generated method stub
> }
> });
>
> On Sep 8, 5:24 am, haig <[EMAIL PROTECTED]> wrote:
>
> > I am having similar problems, hope someone can help.
>
> > In my example, "myService" is a GoogleService
>
> > GoogleService myService = new GoogleService("blogger", "exampleCo-
> > exampleApp-1");
>
> > Standalone client works fine, but not in myandroidapp.
>
> > Error from logcat:
>
> > com.google.gdata.util.AuthenticationException: Error connecting with
> > login URI
> > at
> > com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(Unknown
> > Source)
> > at
> > com.google.gdata.client.GoogleAuthTokenFactory.setUserCredentials(Unknown
> > Source)
> > at
> > com.google.gdata.client.GoogleService.setUserCredentials(Unknown
> > Source)
> > at
> > com.google.gdata.client.GoogleService.setUserCredentials(Unknown
> > Source)
> > at com.travelrecorder.network.Blogger.publish_post(Blogger.java:
> > 32)
> > at com.travelrecorder.network.AlarmService_Service
> > $1.run(AlarmService_Service.java:71)
> > at java.lang.Thread.run(Thread.java:914)
> > Caused by: java.io.IOException:Hostname<www.google.com> was not
> > verified
> > at
> > org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.getSecureSocket(HttpConnection.java:
> > 169)
> > at
> > org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnection
> > $HttpsEngine.connect(HttpsURLConnection.java:398)
> > at
> > org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection...
> > 1129)
> > at
> > org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnection.getOutputStream(HttpsURLConnect...
> > 262)
> > at
> > com.google.gdata.client.GoogleAuthTokenFactory.makePostRequest(Unknown
> > Source)
> > ... 7 more
>
> > On Aug 25, 1:40 pm, "Justin (Google Employee)" <[EMAIL PROTECTED]>
> > wrote:
>
> > > You didn't answer what type "myService" is here.
>
> > > Cheers,
> > > Justin
> > >AndroidTeam @ Google
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---