Twitther Auth failed for failing to find the certificate path

android
login

#1

hi, I am implementing a simple Twitter sign on feature on my Android app, and I got the following Auth errors, can some one help me to take a look?

03-18 15:23:33.818 1489-1489/ E/Twitter﹕ Failed to get request token
com.twitter.sdk.android.core.TwitterApiException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:390)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at retrofit.Platform$Android$2$1.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:841)
03-18 15:23:33.883 1489-1489/ E/Twitter﹕ Authorization completed with an error
com.twitter.sdk.android.core.TwitterAuthException: Failed to get request token
at com.twitter.sdk.android.core.identity.OAuthController$1.failure(OAuthController.java:95)
at com.twitter.sdk.android.core.internal.oauth.OAuth1aService$1.failure(OAuth1aService.java:213)
at com.twitter.sdk.android.core.Callback.failure(Callback.java:45)
at retrofit.CallbackRunnable$2.run(CallbackRunnable.java:53)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5350)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)


#2

Hey @ttliu1, I think I responded to a similar question here: https://twittercommunity.com/t/got-an-error-about-api-key/63369/10


#3

yes thanks. I am not seeing that cert error anymore, but simply “failed to get request token” for “401 Authorization Required”.

It’s strange that it takes a while for the post to show up in this forum.


#4

Thanks - are you building with Gradle? If so, could you share your build.gradle? I’ll close the other thread.


#5
buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/maven/commons-io/commons-io/pom.xml'
        exclude 'META-INF/maven/commons-io/commons-io/pom.properties'
    }

    ext.enableCrashlytics = false

}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'org.apache.commons:commons-io:1.3.2'
    compile 'com.facebook.android:facebook-android-sdk:4.10.0'
    compile 'com.google.apis:google-api-client-android:1.20.0'
    compile 'com.google.android.gms:play-services-auth:8.3.0'
    compile 'com.android.support:design:22.2.0'
//    compile('com.twitter.sdk.android:twitter-core:1.6.5@aar') {
//        transitive = true
//    }
    compile('com.twitter.sdk.android:twitter:1.8.0@aar') {
        transitive = true
    }





}

#6

@bonnell, I found another error happening before that as below, searching online, people said that you should set callback url for the app, and I think I already did.

03-23 10:41:02.368 2682-3073/? E/Parcel﹕ Class not found when unmarshalling: com.twitter.sdk.android.core.TwitterAuthConfig
java.lang.ClassNotFoundException: com.twitter.sdk.android.core.TwitterAuthConfig
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:251)
at java.lang.Class.forName(Class.java:216)
at android.os.Parcel.readParcelableCreator(Parcel.java:2140)
at android.os.Parcel.readParcelable(Parcel.java:2104)
at android.os.Parcel.readValue(Parcel.java:2020)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2321)
at android.os.Bundle.unparcel(Bundle.java:249)
at android.os.Bundle.getString(Bundle.java:1118)
at android.content.Intent.getStringExtra(Intent.java:4995)
at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1351)
at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:974)
at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:3933)
at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:3836)
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:159)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2540)
at android.os.Binder.execTransact(Binder.java:404)
at dalvik.system.NativeStart.run(Native Method)
Caused by: java.lang.NoClassDefFoundError: com/twitter/sdk/android/core/TwitterAuthConfig
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:251)
at java.lang.Class.forName(Class.java:216)
at android.os.Parcel.readParcelableCreator(Parcel.java:2140)
at android.os.Parcel.readParcelable(Parcel.java:2104)
at android.os.Parcel.readValue(Parcel.java:2020)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2321)
at android.os.Bundle.unparcel(Bundle.java:249)
at android.os.Bundle.getString(Bundle.java:1118)
at android.content.Intent.getStringExtra(Intent.java:4995)
at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1351)
at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:974)
at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:3933)
at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:3836)
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:159)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2540)
at android.os.Binder.execTransact(Binder.java:404)


#7

Never mind, the ClassNotFoundException is gone after cleaning the cache. But still getting cert path not found issue.


#8

Thanks @ttliu1, can you let me know if you have this in your AndroidManifest.xml?

<provider android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
            android:authorities="YourApplicationId.google_measurement_service"
            android:exported="false" /> 

If you see com.google. instead of your applicationId, that could be causing a conflict. You can get the full manifest, after it’s been merged,
from:
build/intermediates/manifests/full/release/AndroidManifest.xml


#9

No I haven’t. I’ll add that.

what does it mean by “if you see com.google. instead of your applicationId”?


#10

Still getting the same error. should I add Crashlytics as dependencies in build.gradle too?

3-23 14:41:39.053 3634-3663/ E/Fabric﹕ Unknown error while loading Crashlytics settings. Crashes will be cached until settings can be retrieved.
io.fabric.sdk.android.services.network.HttpRequest$HttpRequestException: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.


#11

Can you unc-omment out the line your build.gradle on TwitterCore and let me know if that changes anything?


#12

@bonnell, I got this problem solved. Thanks!!


#13

Glad to hear it, what did you change? Would love to have it for reference for other developers.


#14

Hello,
I have the exact same problem but can’t figure it out, did you finally find a solution ?


#15

I using retrofit and call url https to https://kenhlaptrinh.net but error

Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
                                             at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(:com.google.android.gms@11951438:21)
                                             at com.google.android.gms.common.net.SSLCertificateSocketFactory.verifyHostname(:com.google.android.gms@11951438:2)
                                             at com.google.android.gms.common.net.SSLCertificateSocketFactory.createSocket(:com.google.android.gms@11951438:8)
                                             at com.android.okhttp.Connection.connectTls(Connection.java:1494)
                                             at com.android.okhttp.Connection.connectSocket(Connection.java:1458)
                                             at com.android.okhttp.Connection.connect(Connection.java:1413)
                                             at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:1700)
                                             at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:133)
                                             at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:466)
                                             at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:371)
                                             at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:503)
                                             at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:130)
                                             at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:261)
                                             at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
                                             at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)
                                             at ujn.a(:com.google.android.gms@11951438:51)
                                             at ujn.a(:com.google.android.gms@11951438:77)
                                             at gus.a(:com.google.android.gms@11951438:4)
                                             at gus.a(:com.google.android.gms@11951438:3)
                                             at fax.a(:com.google.android.gms@11951438:2)
                                             at fbm.b(:com.google.android.gms@11951438:140)
                                             at fbm.a(:com.google.android.gms@11951438:50) 
                                             at ezw.a(:com.google.android.gms@11951438:37) 
                                             at gnu.a(:com.google.android.gms@11951438:7) 
                                             at gnu.a(:com.google.android.gms@11951438:155) 
                                             at gmu.a(:com.google.android.gms@11951438:2) 
                                             at gms.a(:com.google.android.gms@11951438:17) 
                                             at gms.a(:com.google.android.gms@11951438:6) 
                                             at cob.a(:com.google.android.gms@11951438:25) 
                                             at cob.a(:com.google.android.gms@11951438:80) 
                                             at ewz.a(:com.google.android.gms@11951438:6) 
                                             at ewy.a(:com.google.android.gms@11951438:2) 
                                             at ewy.e(:com.google.android.gms@11951438:6) 
                                             at ewx.a(:com.google.android.gms@11951438:1) 
                                             at eyn.getAuthToken(:com.google.android.gms@11951438:7) 
                                             at android.accounts.AbstractAccountAuthenticator$Transport.getAuthToken(AbstractAccountAuthenticator.java:244) 
                                             at android.accounts.IAccountAuthenticator$Stub.onTransact(IAccountAuthenticator.java:113) 
                                             at android.os.Binder.transact(Binder.java:507) 
                                             at cqi.onTransact(:com.google.android.gms@11951438:3) 
                                             at android.os.Binder.execTransact(Binder.java:573)