Closed uynap closed 6 years ago
BTW. I've tried rejectUnauthorized: false. It's just not working. https://github.com/axios/axios/issues/535
I'm stuck on this issue too. #535 suggests to create a custom https agent and set rejectUnauthorized to false however, https module doesn't exist in node_modules. Is there any workaround for this in react native?
+1 Same here
In addition to passing the proper parameter in the constructor (new https.Agent({ rejectUnauthorized: false })
), I needed to put:
https.globalAgent.options.rejectUnauthorized = false;
at the top (per https://github.com/request/request/issues/418#issuecomment-274105600)
You might also try process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
Similar recommendations appear in https://github.com/axios/axios/issues/535
@nickuraltsev @rubennorte seems like this question should be closed - if someone tries this combination and it still doesn't work, should reopen
Also encountered this on axios with react-native
Just use a Free SSL that isn't self-signed instead.
Problem:
Solution:
api_realtycoast_io.crt
(named after the domain I used, which is api.realtycoast.io)AddTrustExternalCARoot.crt
COMODORSAAddTrustCA.crt
COMODORSADomainValidationSecureServerCA.crt
api_realtycoast_io.crt
equivalent as the END ENTITY CERTIFICATECOMODORSADomainValidationSecureServerCA.crt
as the CA CERTIFICATE/ssl
folderprivate.key
file, PASTE YOUR PRIVATE KEY from STEP 1 thereconst fs = require('fs');
const http = require('http');
const https = require('https');
const express = require('express');
const bodyParser = require('body-parser');
const SSL = {
credentials: {
key: fs.readFileSync('ssl/private.key', 'utf8'),
cert: fs.readFileSync('ssl/api_realtycoast_io.crt', 'utf8'),
ca: [
fs.readFileSync('ssl/COMODORSADomainValidationSecureServerCA.crt', 'utf8')
]
}
};
const app = express();
app.use(bodyParser.json());
app.get('/', (req, res) => res.send('Hello World!'));
http.createServer(app).listen(80);
https.createServer(SSL.credentials, app).listen(443);
https://yoursite.com/
that should be working wellhttps://www.sslshopper.com/ssl-checker.html
import { WebView, View } from 'react-native';
// in your component render(), below
return (
<View style={{flex:1}}>
<WebView
source={{uri: 'https://api.realtycoast.io/auth'}}
javaScriptEnabled={true}
domStorageEnabled={true}
startInLoadingState={true}
style={{ flex:1, height: 500, width: 350 }}
/>
</View>
);
// replace your baseURL and url, below
<Button onPress={
()=>{
const x = axios.create({
baseURL: 'https://api.realtycoast.io/',
timeout: 10000,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
});
x.request({
url: '/user/123'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
}
}>
<Text>Axios Test</Text>
</Button>
https://github.com/xemasiv/my-dev-fixes#free-ssl--react-native-apps
@xemasiv this is not a solution, its example how to add ssl on nodejs backend. but we are looking how to allow self-ssl requests on android . okhttp3 restrict self signed certificate
with axios
is there any update on this issue ??
I use the HTTPS backend with a self-signed certificate. I need to tell the HTTP client(fetch) to skip checking the insecure certificate. Otherwise I'm getting "x509: certificate signed by unknown authority" error. As I didn't find any related topics in the documentation. I was wondering what would be your solution or workaround for my situation?