I have seen question on signing and encrypting final mdm profile here: iOS MDM profile signing, which certificate to use?
I am using Bouncy Castle library for encryption. Currently I am stuck while encrypting the final profile using the scep identitiy certificate.
I am facing the following issue.
The public key retrieved from with scep response certificate is not 16byte(128 bit) so encryption is failing with a message Key should be 128 bit.
If I can change the public key to 16byte using the following code the device throws invalid profile dailog.
public static string getKeyMessageDigest(string key) { byte[] ByteData = Encoding.UTF8.GetBytes(key); //MD5 creating MD5 object. MD5 oMd5 = MD5.Create(); byte[] HashData = oMd5.ComputeHash(ByteData); //convert byte array to hex format StringBuilder oSb = new StringBuilder(); for (int x = 0; x < HashData.Length; x++) { //hexadecimal string value oSb.Append(HashData[x].ToString("x2")); } return Convert.ToString(oSb); }
Can some one help me with some blog or sample code to encrypt the profile? Appreciate your help.