私は、Apple デバイス用の自動 VPN プロビジョニング Web ポータルというアプリケーションを Python で作成しました。
気になるのは、テスト サーバーと本番サーバーの動作の違いです。前者は を使用しApache
、後者は を使用していますlighthttpd
。
lighhttpd
ファイルが.mobileconfig
開かれて「実行」されます。たとえば、SysPrefs が自動的に開きますが、Apache ではこれは起こりません。
lighhtpd
は適切な定義に関してはるかに緩いことにすでに気づいていますContent-Type
が、問題は、 では Safari が.mobileconfig
ファイルを適切に読み込んで「自動実行」するのに対しlighthttpd
、 では同じことが起きないということですApache
。
さらに私を苛立たせているのは、両方のサーバーで次mime.type
のように対応するものを適切に定義しているということです。
ライトhttpd.conf
$HTTP["url"] =~ "\.mobileconfig$" {
setenv.add-response-header = ( "Content-Disposition" => "attachment" )
mimetype.assign = (".mobileconfig" => "application/x-apple-aspen-config",
"" => "application/octet-stream")
}
Apache の場合は次のとおりです。
dovpn.conf (仮想ホスト)
AddType application/x-apple-aspen-config .mobileconfig
違いの最初の手がかりは、実際には のadd-response-header
指令から生じているようですlighthttpd
。
生成された HTML には次の内容が含まれます。
a download="profile.mobileconfig" href="../upload/8bd16b26-1473-4994-9803-8268a372cd0d.mobileconfig" type="application/octet-stream">Download automatic profile/a
そしてJavascriptで自動ダウンロードします
//If in Safari - download via virtual link click
if (window.downloadFile.isSafari) {
//Creating new link node.
var link = document.createElement('a');
link.href = sUrl;
if (link.download !== undefined) {
//Set HTML5 download attribute. This will prevent file from opening if supported.
var fileName = sUrl.substring(sUrl.lastIndexOf('/') + 1, sUrl.length);
link.download = fileName;
}
//Dispatching click event.
if (document.createEvent) {
var e = document.createEvent('MouseEvents');
e.initEvent('click', true, true);
link.dispatchEvent(e);
return true;
}
}
生成されたページのコンテンツにも、Content-Type として次のもののみが含まれます。
Content-Type: text/html\n\n
Apache と lighthttpd の両方で。ネットワーク経由でスニッフィングしましたが、 経由で Content-Type に明らかな変更は行われていませんlighthttpd
。
setenv.add-response-header
Apache で同様の機能を再現することはできますか?
すでに Apache ホストに追加しようとしました:
<Files "*.mobileconfig">
Header set Content-Disposition attachment
</Files>
そして
SetEnvIf Request_URI "\.mobileconfig$" change_header
Header set Content-Disposition attachment env=change_header
そして
SetEnvIf Request_URI "\.mobileconfig$" change_header
Header always add "Content-Disposition" "attachment" env=change_header
そして
<Files "*.mobileconfig">
Header append Content-Disposition attachment
</Files>
また、実際のディレクトリで、次.htaccess
のファイルを作成することも試みました:
<IfModule mod_headers.c>
<FilesMatch "\.mobileconfig$">
ForceType application/octet-stream
Header append Content-Disposition "attachment"
Allow from all
</FilesMatch>
</IfModule>
そして
<IfModule mod_headers.c>
<FilesMatch "\.mobileconfig$">
ForceType application/octet-stream
Header add Content-Disposition "attachment"
Allow from all
</FilesMatch>
</IfModule>
どちらの場合も、 のほかにattachment
も使用しました"attachment"
。
Apache/Debian 9 では mod_headers がデフォルトで有効になっており、これらの代替手段はどれも機能しないことに注意してください。
lighthttpd
実は、 HTTP と HTTPS を使用していることを思い出しましたApache
。lighthttpd を HTTPS でテストしましたが、HTTPS でも動作しますが、Apache は動作しません。
curl -k -I https://localhost/cgi-bin/vpn.py
lighthttpd サーバーの出力:
HTTP/1.1 200 OK
Content type: text/html
Content-Length: 331
Date: Thu, 01 Jun 2017 09:03:26 GMT
Server: lighttpd/1.4.45
curl -k -I https://localhost/cgi-bin/vpn.py
Apache サーバーの出力:
HTTP/1.1 200 OK
Date: Thu, 01 Jun 2017 09:05:25 GMT
Server: Apache
Vary: Accept-Encoding
X-Frame-Options: sameorigin
Content-Type: text/html; charset=UTF-8
さらに、Apache でも:
$curl -k -I https://localhost/download/xxx.mobileconfig
HTTP/1.1 200 OK
Date: Thu, 01 Jun 2017 09:13:35 GMT
Server: Apache
Last-Modified: Thu, 01 Jun 2017 03:08:57 GMT
ETag: "1f3b-550dd5b89d8df"
Accept-Ranges: bytes
Content-Length: 7995
X-Frame-Options: sameorigin
Content-Disposition: attachment
Content-Type: application/x-apple-aspen-config
Safari を使用 -> 開発 -> Web インスペクタを表示 -> デバッガ -> メインページをクリック -> curl としてコピーすると、「curl '」のみが返されます。https://xxxx/cgi-bin/vpn.py貼り付けるときに「-Xnull」を使用します。
無効にすることも試しましたX-Frame-Options: "sameorigin"
が、違いはありませんでした(それは無理だとわかっていました)
答え1
.htaccess
このファイルを使用することで、ヘッダーに Content-Disposition を追加する問題が解決されたようです。
しかし、機能の複製に伴う問題と、デバッグとテストの複雑さの増加については、別の説明があるようです。
最新のベータ版と現在のバージョンの Sierra アップデート.mobileconfig
ファイルの両方で、セキュリティ上の理由から、Safari の「安全な」ファイルのリストからファイルが削除されたようです。
昨日(または一昨日)、職場で MacOS をアップデートし、今日自宅でアップデートしたところ、.mobileconfig
本番システムでも試作システムでもファイルが自動的に開かなくなりました。
iPhone を iOS 10.3.3 ベータ版にアップデートしたところ、Apple が.mobileconfig
プロビジョニング ファイルを潜在的に危険なものとして扱う傾向が再確認されたようです。現在、そのようなファイルをクリックすると、新しい警告が表示されます。
このウェブサイトは設定を開いて構成プロファイルを表示しようとしています。これを許可しますか?
無視 - 許可