Cannot download file from server with a self signed certificate
Versions
"react": "16.6.1",
"react-native": "0.57.5",
"react-native-fs": "^2.12.1"
Problem
I want to download file from the server with a self signed certificate. But I got Java exception:
Error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Code
RNFS.downloadFile({
fromUrl: url, // URL to download file from
toFile: path, // Local filesystem path to save the file to
// headers?: Headers; // An object of headers to be passed to the server
background: true, // Continue the download in the background after the app terminates (iOS only)
discretionary: true, // Allow the OS to control the timing and speed of the download to improve perceived performance (iOS only)
cacheable: false, // Whether the download can be stored in the shared NSURLCache (iOS only, defaults to true)
progressDivider: 0,
})
.promise.then(({
jobId, // The download job ID, required if one wishes to cancel the download. See `stopDownload`.
statusCode, // The HTTP status code
bytesWritten // The number of bytes written to the file
}) => {
console.log('bytesWritten ' + bytesWritten + ' of ' + _contentLength);
if(statusCode === 200) {
resolve(path);
} else {
console.log(statusCode);
reject(new Error('Invalid download status code ' + statusCode));
}
})
.catch(err => {
console.log(err);
Sentry.captureException(err);
reject(err);
});
I found this issue and did like he said . But still get this error. I assume, that some work should be done inside of react-native-fs. I found, that rn-fetch-blob has trusty prop for downloading files from servers with self signed certificates. But I am not Java guy, so I don't know how to implement such prop in the react-native-fs. Does react-native-fs have this possibillity?
@NeliHarbuzava I have the same issue, Did you manage to fid any solution?
Hi, @AntwanSherif even I have the same issue, Did you find the solution?
+1
+1