title: Apple iOS MDM Server Setup Device Enrollment/Configuration
body: <p>We are trying to setup our own internal iOS MDM server, and we were having some issues in that what we see doesn't neccessarily match up with what we expect, based on the Apple documentation.</p>
  
  <p>Following the instructions on the Apple site, we setup a webpage where a user can enroll their device by clicking on a link. This link causes the device to go through the "Device Registration Process", as depicted in Figure 1.1 of Apples "Over-The-Air Profile Delivery and Configuration" document: <a href="https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/iPhoneOTAConfiguration/Introduction/Introduction.html" rel="nofollow">https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/iPhoneOTAConfiguration/Introduction/Introduction.html</a></p>
  
  <p>Our question is this:
  We have things functioning as expected up to the beginning of Phase 3 (Device Configuration) in the above mentioned document. However, when we take a look at the traffic between our web server and the device, it appears that the enrollment flow is executed twice. These are the calls we expect to see to our server, based on the documentation:</p>
  
  <pre><code>/enroll
  /scep?operation=GetCACert&amp;message=EnrollmentCAInstance
  /scep?operation=GetCACaps&amp;message=EnrollmentCAInstance
  /scep?operation=PKIOperation&amp;message=MII.....AAA
  </code></pre>
  
  <p>However, in reality, we see that block of calls executed twice, right after each other, with what appears to be identical data. Has anyone seen that behavior, and is it expected?</p>
  
  <p>A more pressing question is that after Phase 2, Step 3 is executed, we pass down the generated cert to the device, which successfully gets installed. However, according to the document, at this point we should get a response back from the device, to which we can reply with a new configuration profile, with the settings we want to set on the device. However, we never get that response, even though everything up to that point appears to have completed successfully.
  Does anyone know why the response isn't being sent, or what could be going wrong at that point?</p>
  
  <p>Thanks in advance,</p>
  
  <p>Device logs retrieved using the iphone configuration utility:</p>
  
  <pre><code>&lt;Notice&gt;: (Note ) MC: Profile “com.test.profileservice.scep” queued for installation.
  &lt;Notice&gt;: (Note ) MC: Checking for MDM installation...
  &lt;Notice&gt;: (Note ) MC: ...finished checking for MDM installation.
  &lt;Notice&gt;: (Note ) MC: Enrolling in OTA Profile service...
  &lt;Error&gt;: Jan 25 16:34:13  SecTrustEvaluate  [leaf AnchorTrusted]
  &lt;Error&gt;: Jan 25 16:34:14  SecTrustEvaluate  [leaf AnchorTrusted]
  &lt;Notice&gt;: (Note ) MC: Attempting to retrieve issued certificate...
  &lt;Notice&gt;: (Note ) MC: Issued certificate received.
  &lt;Notice&gt;: (Note ) MC: Retrieving profile from OTA Profile service...
  &lt;Notice&gt;: (Note ) MC: Received final profile: Test Config
  &lt;Notice&gt;: (Note ) MC: Beginning profile installation...
  &lt;Error&gt;: Jan 25 16:34:17  SecTrustEvaluate  [leaf AnchorTrusted]
  &lt;Notice&gt;: (Note ) MC: Attempting to retrieve issued certificate...
  &lt;Notice&gt;: (Note ) MC: Issued certificate received.
  &lt;Notice&gt;: (Note ) MC: Profile “Test Config” installed.
  &lt;Error&gt;: Checking for changed log settings
  &lt;Error&gt;: valid 0 value 0
  &lt;Error&gt;: Verbose logging disabled
  &lt;Notice&gt;: (Note ) MC: mc_mobile_tunnel starting.
  &lt;Notice&gt;: (Note ) MC: mc_mobile_tunnel shutting down.
  </code></pre>
  
  <p>Complete flow of requests sent to the MDM server:</p>
  
  <pre><code>/enroll
  /checkin
  /scep?operation=GetCACert&amp;message=EnrollmentCAInstance
  /scep?operation=GetCACaps&amp;message=EnrollmentCAInstance
  /scep?operation=PKIOperation&amp;message=MII.....AAA
  /checkin
  /scep?operation=GetCACert&amp;message=EnrollmentCAInstance
  /scep?operation=GetCACaps&amp;message=EnrollmentCAInstance
  /scep?operation=PKIOperation&amp;message=MII.....AAA
  </code></pre>
  
  <p>Adding payload sent back as part of the SCEP configuration:</p>
  
  <pre><code>&lt;plist version="1.0"&gt;
    &lt;dict&gt;
      &lt;key&gt;PayloadVersion&lt;/key&gt;
      &lt;integer&gt;1&lt;/integer&gt;
      &lt;key&gt;PayloadUUID&lt;/key&gt;
      &lt;string&gt;Ignored&lt;/string&gt;
      &lt;key&gt;PayloadType&lt;/key&gt;
      &lt;string&gt;Configuration&lt;/string&gt;
      &lt;key&gt;PayloadIdentifier&lt;/key&gt;
      &lt;string&gt;Test Config&lt;/string&gt;
      &lt;key&gt;PayloadDisplayName&lt;/key&gt;
      &lt;string&gt;Test Profile:SCEP&lt;/string&gt;
      &lt;key&gt;PayloadContent&lt;/key&gt;
      &lt;array&gt;
        &lt;dict&gt;
          &lt;key&gt;PayloadContent&lt;/key&gt;
          &lt;dict&gt;
            &lt;key&gt;URL&lt;/key&gt;
            &lt;string&gt;https://test.com/mdm_scep&lt;/string&gt;
            &lt;key&gt;Name&lt;/key&gt;
            &lt;string&gt;EnrollmentCAInstance&lt;/string&gt;
            &lt;key&gt;Subject&lt;/key&gt;
            &lt;array&gt;
              &lt;array&gt;
                &lt;array&gt;
                  &lt;string&gt;O&lt;/string&gt;
                  &lt;string&gt;Test Organization, Inc.&lt;/string&gt;
                &lt;/array&gt;
              &lt;/array&gt;
              &lt;array&gt;
                &lt;array&gt;
                  &lt;string&gt;CN&lt;/string&gt;
                  &lt;string&gt;test.com&lt;/string&gt;
                &lt;/array&gt;
              &lt;/array&gt;
            &lt;/array&gt;
            &lt;key&gt;Challenge&lt;/key&gt;
            &lt;string&gt;DummyChallenge&lt;/string&gt;
            &lt;key&gt;Keysize&lt;/key&gt;
            &lt;integer&gt;1024&lt;/integer&gt;
            &lt;key&gt;Key Type&lt;/key&gt;
            &lt;string&gt;RSA&lt;/string&gt;
            &lt;key&gt;Key Usage&lt;/key&gt;
            &lt;integer&gt;5&lt;/integer&gt;
          &lt;/dict&gt;
          &lt;key&gt;PayloadDescription&lt;/key&gt;
          &lt;string&gt;Provides device encryption identity&lt;/string&gt;
          &lt;key&gt;PayloadUUID&lt;/key&gt;
          &lt;string&gt;12345678-1234-1234-1234-123456789012&lt;/string&gt;
          &lt;key&gt;PayloadType&lt;/key&gt;
          &lt;string&gt;com.apple.security.scep&lt;/string&gt;
          &lt;key&gt;PayloadDisplayName&lt;/key&gt;
          &lt;string&gt;Encryption Identity&lt;/string&gt;
          &lt;key&gt;PayloadVersion&lt;/key&gt;
          &lt;integer&gt;1&lt;/integer&gt;
          &lt;key&gt;PayloadOrganization&lt;/key&gt;
          &lt;string&gt;Test Organization, Inc.&lt;/string&gt;
          &lt;key&gt;PayloadIdentifier&lt;/key&gt;
          &lt;string&gt;com.test.profileservice.scep&lt;/string&gt;
        &lt;/dict&gt;
      &lt;/array&gt;
    &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>