はじめに
- macOSにて,ダウンロードしたアプリケーションを実行しようとした時に「開発元を確認できないため、開けませんでした。」と表示される.ネットを検索すると,この時の会場方法について指南するサイトは多くあるけれど,仕組みについて説明されたものがなかったので,まとめてみる.
現象の確認 High Sierraを利用
- ダウンロードしたアプリのインストーラ(.pkg方式)を実行しようとすると,次のようなダイアログが出る.
- これはマルウェア(ウイルスなどの悪意のあるソフトウェアの総称)を誤ってダウンロードしても意図せずに実行しないように制御しているのだが,この機能がmacOSのGatekeeper.
- このようにブロックされたアプリは,[システム環境設定]の[セキュリティとプライバシー]を開くと確認できる.
- ここで[このまま開く]ボタンを押下すると,次のようなダイアログが表示される.
- 先ほどとはメッセージが変わった.一度許可すると,「常に許可」される.
- 今回の場合はインストーラなので,いくらでもインストールが可能.(普通は何度もインストールしないか)
- これで[開く]を選択すると,プログラムが実行される.
- 今回の場合,pkgファイルなのでインストールが実行できる.
macOS 10.14 Mojaveでの動作
- macOSはバージョンアップの都度,デフォルト設定を強化していて,MojaveでのmacOS Gatekeeperのダウンロードしたアプリケーションの実行許可は,次のようにApp Storeから限定とされている.
- ダイアログにも,控えめにApp Storeのみと書かれている.
- ダウンロードしたアプリケーションを開こうとすると,管理者権限が必要になる.
High SierraからMojaveへバージョンアップした時のデフォルトの違い
- Mojave(10.14)ではダウンロードしたアプリケーションの実行許可は,App Storeになっている.
- 以前のHigh Sierra(10.13)では,「確認済みの開発元からのアプリケーションを許可」がデフォルトになっていたが,Mojaveへバージョンアップした場合は,デフォルトはHigh Sierraの設定が継承される.
確認済みの開発元とはなんなのか
- Appleが承認したアプリケーションベンダを「確認済みの開発元」というが,これはDeverloperに登録し,Developer IDを取得している事が求められている.
- このDeveloper IDで署名したアプリに限り,Cloudkit,Apple Push Notificationsという機能を実装できるという飴と鞭戦略もある模様.
ダウンロードしたpkgの証明書を確認する
- ダウンロードしたpkgが持っている証明書は,pkgutilを使うことで確認できる.
- 次の例では,MicrosoftのサイトからダウンロードしたMicrosoft Teamsのパッケージファイルを確認.
$ pkgutil --check-signature Downloads/Teams_osx.pkg🆑
Package "Teams_osx.pkg":
Status: signed by a certificate trusted by Mac OS X
Certificate Chain:
1. Developer ID Installer: Microsoft Corporation (UBF8T346G9)
SHA1 fingerprint: F3 13 36 F7 FF AC 5E 8B 2E 9B 1C 7A 88 84 B0 96 02 0A 4C 19
-----------------------------------------------------------------------------
2. Developer ID Certification Authority
SHA1 fingerprint: 3B 16 6C 3B 7D C4 B7 51 C9 FE 2A FA B9 13 56 41 E3 88 E1 86
-----------------------------------------------------------------------------
3. Apple Root CA
SHA1 fingerprint: 61 1E 5B 66 2C 59 3A 08 FF 58 D1 4A E2 24 52 D1 98 DF 6C 60
$
- MicrosoftのDeveloper IDが登録されている.
ダウンロードしたDMGファイルをspctlコマンドで確認する
- DMGファイルは,Disk Imageファイル.昔のフロッピーディスクを貸そうかしていた頃から使われているけれど,macOS用のアプリを入手した際に,DMGファイル形式でダウンロードされるものも多い.
$ spctl🆑
System Policy Basic Usage:
spctl --assess [--type type] [-v] path ... # assessment
spctl --add [--type type] [--path|--requirement|--anchor|--hash] spec ... # add rule(s)
spctl [--enable|--disable|--remove] [--type type] [--path|--requirement|--anchor|--hash|--rule] spec # change rule(s)
spctl --status | --master-enable | --master-disable # system master switch
Kernel Extension User Consent Usage:
spctl kext-consent <action> ** Modifications only available in Recovery OS **
status
Print whether kernel extension user consent is enabled or disabled.
enable
Enable requiring user consent for kernel extensions.
disable
Disable requiring user consent for kernel extensions.
add <team-id>
Insert a new Team Identifier into the list allowed to load kernel extensions without user consent.
list
Print the list of Team Identifiers allowed to load without user consent.
remove <team-id>
Remove a Team Identifier from the list allowed to load kernel extensions without user consent.
$
今回は,Microsoft Office互換ソフトのLibreOfficeをダウンロードしたものを使って検証する.
$ spctl -a -t open --context context:primary-signature -v Downloads/LibreOffice_6.4.4_MacOS_x86-64.dmg🆑
Downloads/LibreOffice_6.4.4_MacOS_x86-64.dmg: rejected
source=no usable signature🈁
$
$ spctl -a -t open --context context:primary-signature -v Downloads/IINA.v1.0.4.dmg🆑
Downloads/IINA.v1.0.4.dmg: rejected
source=Developer ID🈁
$
インストールしたMac Appの開発元を確認する
- すでにインストールされているアプリが,Appleに証明されているか確認する.
- 調べたいアプリを,codesignコマンドで指定する.
- まずは,App Storeからインストールした,Monosnapを.
$ codesign --display -vvv /Applications/Monosnap.app🆑
Executable=/Applications/Monosnap.app/Contents/MacOS/Monosnap
Identifier=com.monosnap.monosnap
Format=app bundle with Mach-O thin (x86_64)
CodeDirectory v=20200 size=58133 flags=0x200(kill) hashes=1809+5 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=03bb860ec5dfca4c5b75e649edf9554c60587adc
Hash choices=sha256
CDHash=03bb860ec5dfca4c5b75e649edf9554c60587adc
Signature size=4617
Authority=Apple Mac OS Application Signing🈁
Authority=Apple Worldwide Developer Relations Certification Authority
Authority=Apple Root CA
Info.plist entries=36
TeamIdentifier=8DEE75ARD7
Sealed Resources version=2 rules=13 files=427
Internal requirements count=1 size=224
$
- 次に,pkgファイルをダウンロードしてインストールしたMicrosoft Teamsを確認.
$ codesign --display -vvv /Applications/Microsoft\ Teams.app🆑
Executable=/Applications/Microsoft Teams.app/Contents/MacOS/Teams
Identifier=com.microsoft.teams
Format=app bundle with Mach-O thin (x86_64)
CodeDirectory v=20500 size=383 flags=0x10000(runtime) hashes=3+5 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha1=de20994eafa3411c1c5e35679925ca09ec1a94c7
CandidateCDHash sha256=ef8f97a75abc383dff7936fdd5d8e395aefbf3a8
Hash choices=sha1,sha256
CDHash=ef8f97a75abc383dff7936fdd5d8e395aefbf3a8
Signature size=9061
Authority=Developer ID Application: Microsoft Corporation (UBF8T346G9)🈁
Authority=Developer ID Certification Authority
Authority=Apple Root CA
Timestamp=2020/04/02 7:48:09
Info.plist entries=18
TeamIdentifier=UBF8T346G9
Runtime Version=10.12.0
Sealed Resources version=2 rules=13 files=129
Internal requirements count=1 size=180
$
$ codesign --display -vvv /Applications/Safari.app🆑
Executable=/Applications/Safari.app/Contents/MacOS/Safari
Identifier=com.apple.Safari
Format=app bundle with Mach-O thin (x86_64)
CodeDirectory v=20100 size=321 flags=0x2000(library-validation) hashes=3+5 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=ab20751f33bbb1371b91a81ea316e297901bcc3e
Hash choices=sha256
CDHash=ab20751f33bbb1371b91a81ea316e297901bcc3e
Signature size=4485
Authority=Software Signing
Authority=Apple Code Signing Certification Authority🈁
Authority=Apple Root CA
Info.plist entries=40
TeamIdentifier=not set
Sealed Resources version=2 rules=13 files=1932
Internal requirements count=1 size=64
$
- んー.どこ見れば良いのかよくわからん.今日はここまで.