我有一个配置配置文件MDM有效载荷和Wifi有效载荷。我脑子里没几个问题
发布于 2014-04-21 22:24:02
1)我认为你说的是身份简介(vs身份简介)。
此配置文件为设备提供一些身份(证书和私钥),它将用于对服务器进行身份验证。
它可以是PKCS12 (它是将证书和密钥结合在一起的格式),也可以是SCEP (它是获取证书的协议)。
2) MDM配置文件始终是可移动的(除了设备受到监视时的情况)。
3)这正是使用身份有效载荷的地方。您应该使用此设备的证书加密配置文件。因此,如果您需要加密配置文件并将其发送到5个不同的设备,那么您实际上需要对这5个设备中的每个设备都具有理想性(certs),并且需要创建该配置文件的5个副本,并使用每个证书进行加密。
发布于 2022-07-27 01:22:49
I can only answer your third question, how to encrypt mobileconfig file? For this I wrote a utility class
/**
* encryption moblicconfig file
* @param configPath moblic filepath ./data/123.mobileconfig
* @param outPath encrypted moblic filepath ./data/123.mobileconfig
* @param certPath certpath ./data/cert.pem
* @throws IOException
* @throws ParserConfigurationException
* @throws ParseException
* @throws SAXException
* @throws PropertyListFormatException
*/
public static void encryptionMobile(String configPath,String outPath,String certPath) throws IOException, ParserConfigurationException, ParseException, SAXException, PropertyListFormatException {
NSDictionary rootDict = (NSDictionary) PropertyListParser.parse(FileUtil.readBytes(new File(configPath)));
String payloadContent = rootDict.get("PayloadContent").toXMLPropertyList();
File tempPlistPath = new File("./data/web/temp/" + System.currentTimeMillis());
FileUtil.writeBytes(payloadContent.getBytes(StandardCharsets.UTF_8),tempPlistPath);
File tempDer = new File("./data/web/temp/" + System.currentTimeMillis());
String outDer = tempDer.getAbsolutePath();
String certPathFile = new File(certPath).getAbsolutePath();
String cmd = "openssl smime -encrypt -aes128 -nodetach -binary -outform der -in " + tempPlistPath.getAbsolutePath() + " -out " + outDer + " " + certPathFile;
XjmUtil.runtimeExec(cmd);
byte[] bytes = FileUtil.readBytes(new File(outDer));
String EncryptedPayloadContent = Base64.getEncoder().encodeToString(bytes);
rootDict.remove("PayloadContent");
rootDict.put("EncryptedPayloadContent", new NSData(EncryptedPayloadContent));
PropertyListParser.saveAsXML(rootDict,new File(outPath));
FileUtil.del(tempPlistPath);
FileUtil.del(outDer);
}
This is maven dependency
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.14</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.14</version>
</dependency>
https://stackoverflow.com/questions/23199096
复制相似问题