react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

Cannot download file from server with a self signed certificate

Open ghost opened this issue 6 years ago • 5 comments

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?

ghost avatar Mar 28 '19 10:03 ghost

@NeliHarbuzava I have the same issue, Did you manage to fid any solution?

AntwanSherif avatar Jul 21 '20 13:07 AntwanSherif

Hi, @AntwanSherif even I have the same issue, Did you find the solution?

techsophy-242 avatar Sep 16 '21 06:09 techsophy-242

+1

suraj-ingle avatar Sep 13 '22 13:09 suraj-ingle

+1

HenriqueAurelio avatar Dec 13 '22 18:12 HenriqueAurelio