I have a server with SelfSigned certificate. This certificate has been added to the Trusted credentials/User list on the Android 11 device. My application and browser work correctly with it: I can download pdf file from MyServer througt Chrome browser.
My network-security-config.xml
<network-security-config xmlns:tools="http://schemas.android.com/tools">
<base-config cleartextTrafficPermitted="true">
<trust-anchors tools:ignore="AcceptsUserCertificates">
<!-- Trust preinstalled CAs -->
<certificates src="system" />
<!-- Additionally trust user added CAs -->
<certificates src="user" />
</trust-anchors>
</base-config>
</network-security-config>
But, when I try to open pdf file I got SSLHandshakeException from PdfViewerActivity. My code:
Intent pdfIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.myserver.com/example.pdf"));
startActivity(pdfIntent);
Error log:
I/ActivityTaskManager: Displayed com.google.android.apps.docs/com.google.android.apps.viewer.PdfViewerActivity: +163ms
E/HttpUriOpener: general IOException: SSLHandshakeException
E/PdfViewerActivity: fetchFile:https: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Is it bug inside PdfViewerActivity or I have done something wrong? I will appreciate any idea how to fix this problem.
UPD: Trust Anchor not found for Android SSL Connection is NOT the answer to my question. It does not contains information about work with SelfTrusted sertificate on Android 11.