@satya164
@majak
You would have to write your own native module if you want that capability. See: http://stackoverflow.com/a/36368360/4932710
The SO answer also shows a good way to get a real cert for development for free.
@facebook-github-bot answered
Closing this issue as @dsibiski says the question asked has been answered. Please help us by asking questions on StackOverflow. StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only.
Any chance to reconsider this issue? Self signed cert isn't only for development purpose and sometimes it is used on real external system that app developer has no control of. There are also systems that simply just use an invalid certificate and app developer can do nothing about it. So there is a real need for a http client to provide extension points to trust an invalid certificate in a case by case basis.
Both iOS and Android built-in http lib supports it. I didn't see any compelling reason not to even consider supporting it officially in the first place.
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.crtCOMODORSAAddTrustCA.crtCOMODORSADomainValidationSecureServerCA.crtapi_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.htmlimport { 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
Most helpful comment
Any chance to reconsider this issue? Self signed cert isn't only for development purpose and sometimes it is used on real external system that app developer has no control of. There are also systems that simply just use an invalid certificate and app developer can do nothing about it. So there is a real need for a http client to provide extension points to trust an invalid certificate in a case by case basis.
Both iOS and Android built-in http lib supports it. I didn't see any compelling reason not to even consider supporting it officially in the first place.