티스토리 뷰

iOS에 들어가 있는걸 여기에 넣었군요... 늦기는 햇지만 보안상으로 안전하니까

 

네트워크 에러가 발생하는 상황은 파이이상 http를 그냥 사용할 경우입니다.

파이로 빌드하지 않으면 상관없어요. ㅎㅎ

일단 이러한 비슷한 Exception을 뿜어냅니다.

com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE

There was 1 cause:

java.io.IOException(Cleartext HTTP traffic to ~~~~ not permitted)

 call GlideException#logRootCauses(String) for more detail

뭐... 너무 길기는 한데 http를 허용하지 않는다는 이야기 입니다. ㅎㅎ

안드로이드 9 (Lv28) 파이부터 강화된 네트워크 보안정책으로 발생하는 문제입니다.

 

iOS에서도 이랬는데, 모든것을 풀어주는 방법과 하나씩 풀어주는 방법이 있습니다.

 

1. AndroidManifest.xml 파일을 수정

 

<application> 부분에 다음과 같이 추가합니다.

<application
    ...
    android:usesCleartextTraffic="true"
    >
</application>

 

2. networkSecurityConfig 파일을 만듭니다.

 

res/xml/network_security_config.xml 파일을 생성하여 줍니다.

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">test.com</domain>
        <domain includeSubdomains="true">moretest.com</domain>
    </domain-config>
</network-security-config>

의미는 딱 보면 알겠지만 test.com이나 moretest.com 일 경우에는 예외적으로 http를 허용합니다.

 

그리고 manifest에 다음과 같이 넣어줍니다.

<application
    ...
    android:networkSecurityConfig="@xml/network_security_config"
    ...>
</application>

 

3. 빌드 타겟을 파이미만으로 한다.

 

아주 쿨하게 빌드를 파이 미만으로 하여줍니다.

이번에도 강제로 버전을 올리게 한것을 생각하면 언제 막힐지 모릅니다.

 

4. manifest에 targetSandboxVersion을 변경

<manifest android:targetSandboxVersion="1">
    <uses-permission android:name="android.permission.INTERNET"/>
</mainfest>

SandboxVersion 속성값이 높을수록 보안 수준이 높아지게 되는것이어서, Pie로 빌드할 경우에는 2로 하게 되면 usesCleartextTraffic의 기본값이 false가 되게 되어서 이것을 1로 만들어주게 되면 된답니다.

그렇지만 이 경우에 InstantApp을 할 경우에는 Android8이상일 경우에는 2로 설정을 하여 주어야 한다고 합니다. 그래서 하지 않는게 나을거 같고 다른 보안 사항들도 같이 적용되므로 안좋네요.

 

* 결론?

저 같은 경우에는 2번의 경우를 추천을 드립니다.

이유는 https를 사용하는게 좋은 방법이지만 꼭 필요한 경우가 있는데요.

테스트 서버를 만들어서 개발을 할때는 https를 만들어서 개발하지는 않죠...

그래서 저는 웬만하면 test 서버만 등록을 하여서 사용을 합니다.

 

안드로이드 개발자 블로그 : https://android-developers.googleblog.com/2018/04/protecting-users-with-tls-by-default-in.html

 

Protecting users with TLS by default in Android P

Android is committed to keeping users, their devices, and their data safe. One of the ways that we keep data safe is by protecting all data that enters or leaves an Android device with Transport Layer Security (TLS) in transit. As we announced in our Andro

android-developers.googleblog.com

Application Sandbox : https://source.android.com/security/app-sandbox?hl=ko

 

Application Sandbox  |  Android Open Source Project

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함