底辺SE奮闘記

年収300万SEブログ

【Xcode・iOS】"An SSL error has occurred and a secure connection to the server cannot be made."に対処

タイトル通り、

An SSL error has occurred and a secure connection to the server cannot be made.

のエラーに対応します。

上記エラーの原因はHTTPS接続がAppleのセキュリティ水準に達していないことにあります。

検索エンジンで検索するといくらでも回答が出てきますが、以外とハマる点についても言及しておきます。

解決できるエラー文言

An SSL error has occurred and a secure connection to the server cannot be made.
App Transport Security has blocked a cleartext HTTP connection since it is insecure. Use HTTPS instead or add Exception Domains to your app's Info.plist.

などなど

環境

  • Xcode13
  • iOS15

対応

通常の解法

  1. プロジェクトの管理画面を見る
  2. プロジェクトのTARGETSを選択
  3. 「Signing & Capabilities」を開く
  4. 左上の「+ Capability」をクリック
  5. 「App Transport Security Exception」を選択
  6. 「App Transport Security Exception」欄の+を押下し、セキュリティ除外したいドメインを設定。

f:id:uma-no-kawa:20211008141710p:plain

f:id:uma-no-kawa:20211008141755p:plain

f:id:uma-no-kawa:20211008141838p:plain

見逃しやすい?ポイント

上記対応を行なったドメインは「https://~」で接続してはいけない。