Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch fails on some https in android 4 #23151

Closed
seriiix opened this issue Jan 24, 2019 · 2 comments
Closed

Fetch fails on some https in android 4 #23151

seriiix opened this issue Jan 24, 2019 · 2 comments
Labels
Bug 🌐Networking Related to a networking API. Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@seriiix
Copy link

seriiix commented Jan 24, 2019

Environment

React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i5 CPU 760 @ 2.80GHz
Memory: 2.19 GB / 7.99 GB
Binaries:
Yarn: 1.10.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.2.0.0 AI-181.5540.7.32.5014246

Description

Some https URLs request fails on android 4 with no error while it's working on other androids (I've tested on some phones and it fails on 4.4.2 while successful on 5.0.2, 6.0.1, 9)

Reproducible Demo

Create a project and paste the following code into your App.js. Make sure you are running on a device with android 4.4.2. It seems working on android 5+.

import React, {Component} from 'react';
import {Text, View} from 'react-native';

export default class App extends Component {

    componentDidMount() {
        /* this request fails on android 4 while its working on android 5+*/
        fetch('https://jsonplaceholder.typicode.com/posts/1')
            .then(resp => resp.json())
            .then(json => alert(`fail -> ${JSON.stringify(json)}`))
            .catch(err => {
                console.log(err)
            })


        /* this one is successful even on android 4 */
        fetch('https://www.json-generator.com/api/json/get/clfvuKZzOq?indent=2')
            .then(resp => resp.json())
            .then(json => alert(`success -> ${JSON.stringify(json)}`))
    }

    render() {
        return (
            <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
                <Text>https error on android 4</Text>
            </View>
        );
    }
}
@react-native-bot react-native-bot added 🌐Networking Related to a networking API. Platform: Android Android applications. labels Jan 24, 2019
@seriiix
Copy link
Author

seriiix commented Jan 25, 2019

I fixed this problem based on this issue and this gist. I don't know if this issue should remain open or not. It's clearly a problem. Anyway, Here's RN fix to it.

@hramos hramos removed the Bug Report label Feb 6, 2019
facebook-github-bot pushed a commit that referenced this issue Mar 18, 2019
Summary:
This PR adds support to use Conscrypt as Security Provider if available runtime. Consscrypt supports TLS 1.2 on Android 4.x and TLS 1.3 on all Android versions. Fixes issues (ex #23151) with HTTPS connections on Android 4.x.

Just add below to your project build.gradle and it'll use it.

```gradle
implementation('org.conscrypt:conscrypt-android:2.0.0')
```

[Android] [Changed] - Add TLS 1.3 support to all Android versions using Conscrypt.
Pull Request resolved: #23984

Differential Revision: D14506000

Pulled By: cpojer

fbshipit-source-id: 58bf18f7203d20519fb4451bae83f01e2f020a44
grabbou pushed a commit that referenced this issue Mar 22, 2019
Summary:
This PR adds support to use Conscrypt as Security Provider if available runtime. Consscrypt supports TLS 1.2 on Android 4.x and TLS 1.3 on all Android versions. Fixes issues (ex #23151) with HTTPS connections on Android 4.x.

Just add below to your project build.gradle and it'll use it.

```gradle
implementation('org.conscrypt:conscrypt-android:2.0.0')
```

[Android] [Changed] - Add TLS 1.3 support to all Android versions using Conscrypt.
Pull Request resolved: #23984

Differential Revision: D14506000

Pulled By: cpojer

fbshipit-source-id: 58bf18f7203d20519fb4451bae83f01e2f020a44
@dulmandakh
Copy link
Contributor

it's fixed with fab86ee, please see commit description.

@facebook facebook locked as resolved and limited conversation to collaborators Apr 1, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug 🌐Networking Related to a networking API. Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants