network security policy

 

1. 오류상세

   - java.net.UnknownServiceException: CLEARTEXT communication to book.interpark.com not permitted by network security policy

 

2. 사용 Libaray

   - retrofit

 

3. 발생이유

   - URL 호출시 "http" 로 호출 했기때문이다.

   - 예, http://book.interpark.com 

 

4. 해결방법 - 1

   - http를 https 로 변경

       https://book.interpark.com

 

4. 해결방안 - 2

   - 보안 연결인 TLS(Transport Layer Security)연결을 사용 해야 한다.

   - 관련 Link.

   - 방안1: 장점 : 모든 ip 가능

             : Manifest.xml 파일의 Application내에

              android:userClearTextTraffic="true" 를 추가하면

              http 연결을 허용하게 된다.

   - 방안2: 단점 - 저장한 ip만 가능

             : 파일생성 - res>xml>network_security_config.xml
             : 파일내용 -

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

            :  Manifest.xml 파일의 Application내에

               android:networkSecurityConfig="@xml/network_security_config"

5. 비슷한 오류
    - https://farmerkyh.tistory.com/1152

   

        

 

Posted by 농부지기
,