使用签名的 .mobileconfig 文件进行无线 iPhone 设置

注意:这不会将您的配置推送到 iPhone。iPhone 用户必须转到 Web 地址并安装配置文件。

假设您有几部需要支持的 iPhone,但您不想花时间在每部手机中键入所有电子邮件(IMAP 或 POP)、LDAP、无线网络或其他设置。也许你已经找到了 Apple 的企业部署指南,但你真的不想建立一个完整的 SCEP 证书颁发机构来完成工作,因为你的要求非常简单。但是你确实意识到,告诉你的用户在他们的iPhone上去 https://example.com/iphone/ 比让他们完成所有单独的设置例程要容易得多。

令人惊讶的是,关于如何手动滚动 .mobileconfig 文件的文档并不多,您可以在 HTTPS 服务器上将其传递给您的用户。我们还希望它由 iPhone 进行“验证”,以便您的用户可以看到它来自您。虽然他们可以安装不受信任的配置文件,但绿色复选标记肯定会增加一个很好的触感。

也许你已经在互联网上搜索过,因为你已经读到你可以“只使用”来签署你的.mobileconfig文件,但似乎没有人告诉你怎么做。我们也会在这里讨论这个问题。openssl smime

1) 创建配置 (.mobileconfig) 文件

此文件将包含您想要的用户 iPhone 的所有配置。我相信您可以使用 Apple 的 iPhone 配置实用程序来创建此文件。您不必这样做,但它可能会为您节省一些打字时间。

《企业部署指南》定义了附录 B 中配置文件的语法。您可以在手机和服务器之间执行一些非常花哨的请求/响应脚本,但我将介绍一种更简单的方法,该方法仅将配置文件从Web服务器发送到他们的手机。

您的 .mobileconfig 文件最终将如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>PayloadContent</key>
	<array>
		<dict>
			<key>PayloadDisplayName</key>
			<string>LDAP Settings</string>
			<key>PayloadType</key>
			<string>com.apple.ldap.account</string>
			<key>PayloadVersion</key>
			<integer>1</integer>
			<key>PayloadUUID</key>
			<string>6df7a612-ce0a-4b4b-bce2-7b844e3c9df0</string>
			<key>PayloadIdentifier</key>
			<string>com.example.iPhone.settings.ldap</string>
			<key>LDAPAccountDescription</key>
			<string>Company Contacts</string>
			<key>LDAPAccountHostName</key>
			<string>ldap.example.com</string>
			<key>LDAPAccountUseSSL</key>
			<false />
			<key>LDAPAccountUserName</key>
			<string>uid=username,dc=example,dc=com</string>
			<key>LDAPSearchSettings</key>
			<array>
				<dict>
					<key>LDAPSearchSettingDescription</key>
					<string>Company Contacts</string>
					<key>LDAPSearchSettingSearchBase</key>
					<string></string>
					<key>LDAPSearchSettingScope</key>
					<string>LDAPSearchSettingScopeSubtree</string>
				</dict>
				<dict>
					<key>LDAPSearchSettingDescription</key>
					<string>Sales Departments</string>
					<key>LDAPSearchSettingSearchBase</key>
					<string>ou=Sales,dc=example,dc=com</string>
					<key>LDAPSearchSettingScope</key>
					<string>LDAPSearchSettingScopeSubtree</string>
				</dict>
			</array>
		</dict>
		<dict>
			<key>PayloadDisplayName</key>
			<string>Email Settings</string>
			<key>PayloadType</key>
			<string>com.apple.mail.managed</string>
			<key>PayloadVersion</key>
			<integer>1</integer>
			<key>PayloadUUID</key>
			<string>362e5c11-a332-4dfb-b18b-f6f0aac032fd</string>
			<key>PayloadIdentifier</key>
			<string>com.example.iPhone.settings.email</string>
			<key>EmailAccountDescription</key>
			<string>Company E-mail</string>
			<key>EmailAccountName</key>
			<string>Full Name</string>
			<key>EmailAccountType</key>
			<string>EmailTypeIMAP</string>
			<key>EmailAddress</key>
			<string>username@example.com</string>
			<key>IncomingMailServerAuthentication</key>
			<string>EmailAuthPassword</string>
			<key>IncomingMailServerHostName</key>
			<string>imap.example.com</string>
			<key>IncomingMailServerUseSSL</key>
			<true />
			<key>IncomingMailServerUsername</key>
			<string>username@es2eng.com</string>
			<key>OutgoingPasswordSameAsIncomingPassword</key>
			<true />
			<key>OutgoingMailServerAuthentication</key>
			<string>EmailAuthPassword</string>
			<key>OutgoingMailServerHostName</key>
			<string>smtp.example.com</string>
			<key>OutgoingMailServerUseSSL</key>
			<true />
			<key>OutgoingMailServerUsername</key>
			<string>username@example.com</string>
		</dict>
	</array>
	<key>PayloadOrganization</key>
	<string>Your Organization's Name</string>
	<key>PayloadDisplayName</key>
	<string>Organization iPhone Settings</string>
	<key>PayloadVersion</key>
	<integer>1</integer>
	<key>PayloadUUID</key>
	<string>954e6e8b-5489-484c-9b1d-0c9b7bf18e32</string>
	<key>PayloadIdentifier</key>
	<string>com.example.iPhone.settings</string>
	<key>PayloadDescription</key>
	<string>Sets up Organization's LDAP directories and email on the iPhone</string>
	<key>PayloadType</key>
	<string>Configuration</string>
</dict>
</plist>

我将简要介绍上面的配置。据我所知,iPhone 使用 UUID 来了解它是否正在更换或安装新的配置文件到手机上。在 Mac 或 Linux 机器上,您可以使用命令生成 UUID。您会注意到,我没有在上面包含任何密码。通过这些设置,iPhone 将在安装配置文件时提示用户输入其电子邮件密码。(如果登录失败,首次使用时将提示LDAP密码。uuidgen

我实际上编写了一个PHP脚本,该脚本将为我获取模板.mobileconfig文件,并根据PHP_AUTH_USER为我填写用户名字段。在你掌握了基础知识后,你可以回去做这件事。还有一种方法可以加密 .mobileconfig 文件,但我们在这里不介绍。

对 .mobileconfig 文件进行签名

这是其他人似乎没有经历过的部分。对配置文件进行签名是一个可选步骤,但如果您已经拥有 X.509 Web 服务器或电子邮件证书,则不会太难。

对于此步骤,我将使用以下表示法:

  • company.mobileconfig是未签名的配置文件
  • server.crt是用于对配置文件进行签名的服务器证书
  • server.key是服务器的私钥
  • cert-chain.crt是颁发服务器证书的 CA 的证书捆绑包。
  • signed.mobileconfig将是您签名的配置文件

获得上面列出的所有文件后,将运行如下命令:

openssl smime -sign -in company.mobileconfig -out signed.mobileconfig -signer server.crt -inkey server.key -certfile cert-chain.crt -outform der -nodetach

 

和是你真正的门票,把它放在iPhone想要的形式上。现在你开始并进入下一步!-outform der-nodetachsigned.mobileconfig

对那些将使用 PHP 脚本的人的帮助:您需要查看字段设置为 0 的函数。这将创建一个 base-64 编码的文件。去除顶部的电子邮件标题后,可以获得相同的输出。例如:

openssl_pkcs7_sign()$flagsbase64_decode()
$mobileconfig = base64_decode(preg_replace('/(.+\n)+\n/', '', $signed, 1));

 

在 HTTPS 服务器上提供文件
好的,它可能也可以在您的 HTTP 服务器上运行。只是我没有费心测试的另一个配置。

在提供此文件时,只有一个警告。它需要使用 MIME Content-Type 提供 。您可以通过在服务器的配置或文件夹中的 .htaccess 文件中添加一行来执行此操作:

application/x-apple-aspen-config

<IfModule mod_mime.c>
	AddType application/x-apple-aspen-config .mobileconfig
</IfModule>

如果从 PHP 中提供文件,您可以执行以下操作:

header('Content-type: application/x-apple-aspen-config; chatset=utf-8');
header('Content-Disposition: attachment; filename="company.mobileconfig"');
echo $mobileconfig;

在 iPhone 上试用

拿起你的iPhone并加载Safari。转到保存个人资料的网址,例如 https://www.example.com/iphone/。您的手机应该会提示您安装配置文件。

您可以在 iPhone 上的“设置”>“通用”中查看和移除描述文件。请注意,可以创建一个无法删除的配置文件,除非由原始配置文件标识符删除并由同一颁发机构签名。小心不要把自己锁在门外。

完成!

至此,我们完成了。请参阅《企业部署指南》,了解您可以创建的其他配置文件。它不允许您创建或设置我希望它所做的所有事情(尤其是在设置 IMAP 默认值时),但它可以让您做很多事情。

我希望这对你有所帮助!这显然是一个非常简短的指南,我仔细阅读了一些细节。如果您有任何意见,请告诉我。我的电子邮件地址可以从文档的最底部推断出来。

另见

文章版权归原作者所有或来自互联网,未经允许请勿转载。如有侵权请联系我删除,谢谢!
THE END
分享
二维码
打赏
< <上一篇
下一篇>>
文章目录
关闭
目 录