Android: CertPathValidatorException - TrustAnchor found but certificate validation failed - android

I am trying to authenticate my android application over a https connection to the server.
I a getting the following exception while trying to authenticate. While looked up for solution, there were lots of suggestions about binding certificate with apk, ignoring the certificate validation etc.
Detailed StackTrace
The problem is, in few phones and emulators this authentication over https works perfectly fine. And in my phone as well as in my emulator it doesn't go through. So looks like its more of a device issue than code one.
Has anyone else have faced this kind of issue and sorted out?

The error meaning is: the SSL certificate chain (from the server certificate to a trust anchor in the Root CA store) has been rebuild by the application but the validation of this chain failed for any reason.
In the stacktrace the underlying error is java.security.NoSuchProviderException: AndroidOpenSSL. It means that the application tries to instantiate a signature validation object with a cryptographic provider which is not present in the android system. This error makes me thinking that it may be an android version issue.
Can you tell us the target API level used to build your application? And what are the versions of the terminals on which the application works and does not work?

Related

ASP .Net Core with Kestrel implement SSL

i'm facing problem when implementing ssl to my web. My web work as web services for android and ios. All goes very smooth until i implement the SSL certificates, suddenly the android (most of android except samsung) throw this error :
E/ErrorHTTP: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
then i google and landed to here :
google says about the error
support the google statement
work around for the error to accept the not valid ssl
it says that mostly happened because of :
The CA that issued the server certificate was unknown
The server certificate wasn't signed by a CA, but was self signed
The server configuration is missing an intermediate CA
Those three options already ruled out, i already check with ssl checker. Its none of those above, it's not unknown, it's not self signed, we're using comodo and the intermediates and root certificates also valid, you can check here : ssl checker for my link,
you can check it by yourself.
And now i'm stuck, the certificate is valid. The certificate also can open in samsung, but somehow fail in some other brand, for example xiao mi. I don't know where to look now, is it the :
the ssl configuration, i need to keep digging, even though it marked as valid in most validator.
make the android code more vulnerable, even some brand can access it, i mean is it because the brand or how ?.
The spec im using :
ASP .Net Core 2.0.
Kestrel.
Comodo certificates.
Native android.
Please help !, thank you.

Test for SSL attacks - possible to extract certificate of server after SSLException?

For a project, I want to test if anyone is tampering with the SSL connection.
The HttpsUrlConnection is using a SSLContext with a pinned the certificate.
My question is: in case I get an SSLException, e.g. someones is trying to forge a wrong certificate, is there any way to get details about that certificate?
On a computer, using a browser (depending on browser and version) I will get a certificate warning and have an option to see details about the certificate.
I was wondering, if there is any way to get this using the HttpsUrlConnection or would there be another possibility?
getServerCertificates()will not work at this point, as the connection has not been established, and I see no other option..
It turns out that starting from Android SDK 22, the exception thrown already includes details about the certificate.
I could witness that devices running Android 21 would throw an IOException (Hostname not verified), while Android 22 is throwing an SSLPeerUnverifiedException, also giving details about the certificate.

Invalid certificate received from server

WebAPI (built with .Net) is hosted on a server and called from iOS and Android apps using HTTPS. No changes has been made in certificates or otherwise. iOS app works fine, web app using the same api works fine but since this morning all Android apps (running on Android version 5x or less only) using the API has stared crashing with this error.
android.runtime.JavaProxyThrowable: System.AggregateException: One or more errors occurred. ---> System.Net.WebException: Error: TrustFailure (The authentication or decryption has failed.) ---> System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server.
Checked certificates, certificate chain, everything. No issues. If the certificate is invalid, no other apps should be working and why all of a sudden. Can someone point to where to look. I searched this site and found a few threads but their solutions require changes in Android app code. That can't be done (and deployed) so quickly. Why all of a sudden, if someone can throw some light on it. Even nothing has been updated in our test Android devices.
Tested the server through ssllab and handshakes come on Android simulations:
Solved and the app on those older Android versions works now. I had to disable COMODO root certificate COMODO RSA Certification Authority with SHA1 key afe5d244a8d1194230ff479fe2f897bbcd7a8cb4 in certificate manager everywhere it was. Apparently windows update added this and it was somehow conflicting and making an intermediate certificate not being sent from the server (in the second certificate chain, the first chain was ok). Normally if an intermediate certificate is not sent, clients download it from the issuer but Android mono framework apparently doesn't do that.
Thank you Adm Selec https://community.qualys.com/thread/15295 for the solution.

How do I fix incomplete certificate chain in nginx

I'm using a package called coroinium cloud and I have recently set up ssl. Coronium cloud is a server package for apps developed with corona SDK. It uses nginx as the server for the package. There is a control panel that you connect to through your browser which loads fine and firefox says the certificate is trusted. However it does not work on the app but instead shows an error saying the certificate is not trusted (CertPathValidatorException on android). I used a tool by digicert to check the ssl configuration:
screenshot of digicert test
There were instructions by the creator of coronium cloud on how to set it up of which all I followed. I got the certificate from startssl.com and used there Nginx certificate. Does anyone know how I can fix this issue as it is holding me back from developing other features as I now can't use any part of my app till this is fixed.
Thank you in advance to anyone who can help me
You should use the certificate chain provided by your Certificate Authority, in the same time than your certificate, and follow the nxinx documentation:
https://nginx.org/en/docs/http/configuring_https_servers.html#chains
cat www.example.com.crt bundle.crt > www.example.com.chained.crt
And in your server block:
ssl_certificate www.example.com.chained.crt;

Read error: Failure in SSL library, usually a protocol error

I am trying to access an secure url by using a DefaultHttpClient.
I am creating BKS file using portecel tool.
The jks file created using the same is working fine in java program but the bks is throwing the following exception:
java.io.IOException: Read error: Failure in SSL library, usually a protocol error
I am able to open the bks file in a keystore explorer and see the details.
The same is working fine in Android 2.3 but not in 2.2
let me know if anybody has faced such problem and solved it.
I encountered the same problem in one of my applications. After googling a bit I found a bugreport from k9mail which refers to this bugreport on Android 2.2 and some more posts all indicating this is a framework bug in 2.2.
I found several sources like this one mentioning that importing the certificates server-side has to be done in some specific order, in order for Android to accept it. Since I have no control over the server I didn't pursue this option and I have no clue if it actually works; however, it might be interesting for you to investigate further.
Check whether the server want client authentication.
I had this problem with Retrofit Library. I solved this change, "https://10.0.3.2:4567" to "http://10.0.3.2:4567" in my URL connection.

Categories

Resources