iOS/에러
[Swift]네트워크 연결 시 Code=-1200 "SSL 오류가 발생했기 때문에 서버에 안전하게 연결할 수 없습니다. "
택꽁이
2022. 3. 28. 18:34
728x90
API 호출을 했는데 이런 에러가 떳다.

<1> finished with error [-1200] Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made."
검색해보니 IOS10부터는 ATS(App Transport Security)가 강화되어 보안이 안전하지 않은 Https 트래픽을 비활성화 시킨다고 한다.
이거는 Info.plist에서 ATS setting을 수정함으로 해결할 수 있다.


프로젝트 파일의 Info.plist에서 Information Property List 옆의 +버튼을 눌러 App Transport Security Settings 항목을 추가한다.


후에 다음과 같이 설정한다 .
1.
Exception Domain - NSIncludesSubdomains 추가, Boolean type, value를 true 값으로 변경
Exception Domain - NSExceptionAllowsInsecureHTTPLoads 추가, Boolean type, value를 true 값으로 변경
호출할 API의 Https 주소입력
이와 같이 접속할 도메인을 예외처리한다.
2.
혹여나 안되면
App Transport Security Settings - Allow Arbitrary Loads 의 value 를 Yes로 변경
이렇게 변경한 후 시도하면 정상적으로 호출된 것을 확인할 수 있다.
