title: Unable to create SGX enclave in hardware mode - "invalid launch token" even though documentation specifies an invalid launch token as the first one
body: <p>Intel's documentation says <a href="https://software.intel.com/en-us/node/709072" rel="nofollow noreferrer">here</a> that if there is no previous launch token, an "invalid" token with all zeros should be used. This works perfectly in simulation mode, but in hardware mode it returns SGX_ERROR_INVALID_LAUNCH_TOKEN, even though that is exactly what it is asking for.</p>
  
  <pre><code>    // Initialize an "invalid" first token, as the documentation specifies (all zeros)
      sgx_launch_token_t token = {0};
  
      // Create enclave
      sgx_enclave_id_t id;
      int updated = 0;
      const auto status = sgx_create_enclave("enclave.signed.so", SGX_DEBUG_FLAG, &amp;token, &amp;updated, &amp;id, NULL);
  
      if (status != SGX_SUCCESS) {
          throw "Failed to initialize enclave. (" + get_error_message(status) + ")";
      }
  </code></pre>
  
  <p>The code returns status = SGX_ERROR_INVALID_LAUNCH_TOKEN</p>
  
  <pre><code>Failed to initialize enclave. (The launch token is not correct.)
  </code></pre>
  
  <p>Is there maybe anything I'm missing from the building process?</p>