我正在使用 Apple OTA 配置文件交付示例(使用 Ruby 语言)在 C++ 中实现 Apple MDM 配置文件服务。除了最后一步(配置应用)之外,似乎一切都运行良好。
iPhone 配置实用程序显示以下内容:
Jul 8 16:38:48 iPhone profiled[1454] : (Note ) profiled: Service starting...
Jul 8 16:38:48 iPhone profiled[1454] : (Note ) MC: Checking for MDM installation...
Jul 8 16:38:48 iPhone profiled[1454] : (Note ) MC: ...finished checking for MDM installation.
Jul 8 16:38:50 iPhone profiled[1454] : (Note ) MC: Enrolling in OTA Profile service...
Jul 8 16:38:51 iPhone profiled[1454] : (Note ) MC: Attempting to retrieve issued certificate...
Jul 8 16:38:51 iPhone profiled[1454] : (Note ) MC: Issued certificate received.
Jul 8 16:38:52 iPhone profiled[1454] : (Note ) MC: Retrieving profile from OTA Profile service...
Jul 8 16:38:52 iPhone profiled[1454] : (Error) MC: Decryption failed: NSError:
Desc : Profile could not be decrypted
Sugg : Decryption key for this profile is not installed.
US Desc: Profile could not be decrypted
US Sugg: Decryption key for this profile is not installed.
Domain : MCProfileErrorDomain
Code : 1006
Type : MCFatalError
这似乎是一个常见错误,因为我在discuss.apple.com上找到了一些讨论,但他们没有解决方案。我还发现了a comment在这里,但也没有解决方案。
Apple Ruby 示例位于 Over-the-Air Profile Delivery Concepts效果很好。我比较了 C++ 实现和 Ruby 示例的输出(证书转储)。除了域名之外,它们是相同的(我使用“TEST”而不是“ACME”。我尝试使用原始证书,但它们在我的实现中也不起作用。)。
我在代码中使用相同的加密来将新证书发送到设备端。它有效。
在配置文件加密的情况下,我使用从设备端接收到的 PKCS7 的证书。所以我不认为问题是由于 OpenSSL 的不正确使用造成的。
你能给我建议吗?
更新1:
1)实际上,当我说证书(我的和示例中的)是相同的时,我的意思是它们具有相同的依赖项,并且我的意思是我的算法和示例算法的工作原理类似。当然证书有不同的指纹等。
2) 我使用的算法与无线配置文件交付概念链接中的 Ruby 示例完全相同。据我所知,我使用 SCEP。
这是我的 C++ 代码(我主要删除了日志记录代码)。是的,我知道我的代码很粗糙,但在这个阶段我只需要一个可行的算法。
C-x509-request-from-device.pem
PKCS #10 Certificate Request (Version 1.0)
Subject: CN=Profile Service (4feea0ef-b586-4c54-a767-5d8160a04952), O=TEST Inc.
Public Key: X.509 format RSA key
Extension Request:
#1: ObjectId: 2.5.29.15 Criticality=true
KeyUsage [
DigitalSignature
Key_Encipherment
]
E-pkcs7-degenerate.pem
Owner: CN=Profile Service (4feea0ef-b586-4c54-a767-5d8160a04952), O=TEST Inc.
Issuer: CN=TEST Root CA (314aa3fe-ea1f-4afb-b2f5-ad998f1eddf3), O=None
Serial number: 145
Valid from: Wed Jul 09 22:38:04 NOVT 2014 until: Thu Jul 10 22:38:04 NOVT 2014
Certificate fingerprints:
MD5: B4:F4:78:E3:A1:69:FB:23:49:E8:0D:4C:E5:8F:C5:A6
SHA1: 47:19:8A:9C:9F:91:B2:FC:6B:ED:EE:A8:41:FF:3B:CF:6A:1D:52:F2
SHA256: 59:95:31:66:B8:D8:54:83:B5:23:17:86:1A:7F:94:98:B2:17:58:61:F8:
0A:4C:E8:B0:1C:4D:79:23:B0:32:93
Signature algorithm name: SHA1withRSA
Version: 3
Extensions:
#1: ObjectId: 2.5.29.15 Criticality=true
KeyUsage [
DigitalSignature
Key_Encipherment
]
/profile(第二个 POST;我对此的回复导致“配置文件无法解密”错误)
PKCS7Wrap pkcs7;
pkcs7.InitFromDER(httpData.block_, httpData.blockSize_);
std::string content;
// ...........
SavePKCS7ToFile(pkcs7.pkcs7_, "K-pkcs7-from-device-2.pem");
std::string tmp = appleMDMPList_.GetClientCertConfPayloadPList("foo");
SaveData(tmp, "3-client-cert-conf.xml");
PKCS7Wrap encryptedContent;
PKCS7Wrap::EncryptData(pkcs7.GetCertificates(), tmp, encryptedContent);
if (encryptedContent.IsInited())
{
SavePKCS7ToFile(encryptedContent.pkcs7_, "Q-encrypted_profile.pem");
content =
appleMDMPList_.GetConfigurationPayloadPList(encryptedContent.ToDER());
SaveData(content, "4-configuration.xml");
}
std::string signedProfile;
PKCS7Wrap::SignData(keyStore.GetAppleMDMSSLCrt(),
keyStore.GetAppleMDMSSLKey(), content, signedProfile);
// send to the device with mime = application/x-apple-aspen-config
K-pkcs7-from-device-2.pem
Certificate[1]:
Owner: CN=Profile Service (4feea0ef-b586-4c54-a767-5d8160a04952), O=TEST Inc.
Issuer: CN=TEST Root CA (314aa3fe-ea1f-4afb-b2f5-ad998f1eddf3), O=None
Serial number: 145
Valid from: Wed Jul 09 22:38:04 NOVT 2014 until: Thu Jul 10 22:38:04 NOVT 2014
Certificate fingerprints:
MD5: B4:F4:78:E3:A1:69:FB:23:49:E8:0D:4C:E5:8F:C5:A6
SHA1: 47:19:8A:9C:9F:91:B2:FC:6B:ED:EE:A8:41:FF:3B:CF:6A:1D:52:F2
SHA256: 59:95:31:66:B8:D8:54:83:B5:23:17:86:1A:7F:94:98:B2:17:58:61:F8:
0A:4C:E8:B0:1C:4D:79:23:B0:32:93
Signature algorithm name: SHA1withRSA
Version: 3
Extensions:
#1: ObjectId: 2.5.29.15 Criticality=true
KeyUsage [
DigitalSignature
Key_Encipherment
]
Certificate[2]:
Owner: CN=TEST Root CA (314aa3fe-ea1f-4afb-b2f5-ad998f1eddf3), O=None
Issuer: CN=TEST Root CA (314aa3fe-ea1f-4afb-b2f5-ad998f1eddf3), O=None
Serial number: 1
Valid from: Mon Jul 07 19:28:55 NOVT 2014 until: Tue Jul 07 19:28:55 NOVT 2015
Certificate fingerprints:
MD5: 78:20:18:80:9C:09:D9:DA:36:3E:06:CC:F7:61:A9:13
SHA1: 40:61:EA:90:D8:58:20:3C:43:CB:2B:E1:3F:49:DF:A8:5A:7A:01:39
SHA256: AB:F6:5C:A7:23:F1:92:38:12:71:29:2A:C0:F1:04:69:CF:F4:7C:26:FC:
E7:0C:89:B4:10:A4:E5:58:9F:50:39
Signature algorithm name: SHA1withRSA
Version: 3
Extensions:
#1: ObjectId: 2.5.29.19 Criticality=true
BasicConstraints:[
CA:true
PathLen:2147483647
]
#2: ObjectId: 2.5.29.15 Criticality=true
KeyUsage [
DigitalSignature
Key_CertSign
Crl_Sign
]
更新2:
我刚刚重新生成了证书(CA、RA、SSL)并且它可以工作。我不知道为什么:)
最佳答案
@jww 是对的。没有任何代码就无法解决此类问题。
我的猜测是您正在使用错误的证书加密配置文件。
I have compared outputs (certificate dumps) of my C++ implementation and the Ruby example. >They are the same except domain names (I use "TEST" instead of "ACME".
坦率地说。这句话在我脑海中升起危险信号。应该不止是域名的区别。应该有公钥差异,序列号差异等。
最有可能发生的情况是您将一个证书发送到设备并使用另一个证书来加密配置文件。
顺便说一句。您是否使用 PKCS12 或 SCEP 为您的设备提供身份?
关于ios - Apple MDM - 无法解密配置文件(未安装此配置文件的解密 key ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24629873/