react-native-pdf
react-native-pdf copied to clipboard
Unable to show PDF if `trustAllCerts = true`
What react-native
version are you using?
0.61.5
What react-native-pdf
version are you using?
6.1.2
What platform does your issue occur on? (android/ios/both) Android
Describe your issue as precisely as possible :
- Steps to reproduce the issue or to explain in which case you get the issue
Didn't try the example project, but here's a sample code
const source = { uri: 'http://samples.leanpub.com/thereactnativebook-sample.pdf', cache: true, }; <PDF source={source} onLoadComplete={(numberOfPages, filePath) => { console.log(
number of pages: ${numberOfPages}); }} onPageChanged={(page, numberOfPages) => { console.log(
current page: ${page}); }} onError={(error) => { console.log(error); }} onPressLink={(uri) => { console.log(
Link presse: ${uri}); }} trustAllCerts={false} style={{flex: 1}} />
- Interesting
logs
[Error: RNFetchBlob request error: java.lang.IllegalStateException: Unable to extract the trust manager on AndroidPlatform, sslSocketFactory is class org.conscrypt.OpenSSLSocketFactoryImpljava.lang.IllegalStateException: Unable to extract the trust manager on AndroidPlatform, sslSocketFactory is class org.conscrypt.OpenSSLSocketFactoryImpl]
Join a screenshot or video of the problem on the simulator or device?
--
I'm aware that this could be an rn-fetch-blob
issue, but I also thought that it's much safer if trustAllCerts
is set to false by default.
I have tested the following links:
- http://www.africau.edu/images/default/sample.pdf
- https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf
And they all work fine
I'm also facing the same issue. @marqroldan Any solution for this?
setting
trustAllCerts={false}
did the trick on my end
setting
trustAllCerts={false}
did the trick on my end
Really helped. Thanks
Thanks man, Really helped!!
Came across the same problem today and I honestly don't understand why this option is enabled by default.
As far as I understand, this basically enables the trusty
option of react-native-blob-util, which on Android also requires setting up a trust manager.
But not only that, I think from a security perspective it's also less secure or to quote from react-native-blob-util:
By default, react-native-blob-util does NOT allow connection to unknown certification provider since it's dangerous.
Source: https://github.com/RonRadtke/react-native-blob-util#self-signed-ssl-server
I think this option should be disabled by default as in most cases you shouldn't need it anyway. If you need self-signed certificates you can still enable it and implement the trust manager.