You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to do do SSL Pinning for my app and the Lets Encrypt certificate (ISRG Root X1) is returning CertPathValidatorException: Trust anchor for certification path not found.
I've tried changing certificates but no luck, I've read on one of these issues that its the key store but still didn't work out.
I'm on Android Studios using Kotlin, using Fuel for the web requests, here is the code I have, thanks!
funpinning(ctx:Context): Pair<SSLSocketFactory, KeyStore> {
val cf:CertificateFactory=CertificateFactory.getInstance("X.509")
val caInput:InputStream=BufferedInputStream(ctx.resources.openRawResource(R.raw.isrgrootx1))
val ca:X509Certificate= caInput.use {
cf.generateCertificate(it) asX509Certificate
}
Log.println(Log.DEBUG, "SYSTEM-CA", ca.subjectDN.toString())
// Create a KeyStore containing our trusted CAsval keyStoreType =KeyStore.getDefaultType()
val keyStore =KeyStore.getInstance(keyStoreType).apply {
load(null, null)
setCertificateEntry("ca", ca)
}
// Create a TrustManager that trusts the CAs inputStream our KeyStoreval tmfAlgorithm:String=TrustManagerFactory.getDefaultAlgorithm()
val tmf:TrustManagerFactory=TrustManagerFactory.getInstance(tmfAlgorithm).apply {
init(keyStore)
}
// Create an SSLContext that uses our TrustManagerval context:SSLContext=SSLContext.getInstance("TLS").apply {
init(null, tmf.trustManagers, null)
}
returnPair(context.socketFactory, keyStore)
}
val (pin, key) = pinning(this)
FuelManager.instance.socketFactory = pin
FuelManager.instance.keystore = key
Log.println(Log.INFO, "FUEL-MANAGER", "Imported instances successfully")
The FuelManager is run as soon as the app starts (override fun onStart())
The text was updated successfully, but these errors were encountered:
Good evening everyone,
I'm trying to do do SSL Pinning for my app and the Lets Encrypt certificate (ISRG Root X1) is returning
CertPathValidatorException: Trust anchor for certification path not found.
I've tried changing certificates but no luck, I've read on one of these issues that its the key store but still didn't work out.
I'm on Android Studios using Kotlin, using Fuel for the web requests, here is the code I have, thanks!
The
FuelManager
is run as soon as the app starts (override fun onStart()
)The text was updated successfully, but these errors were encountered: