title: Cant connect to AWS IoT Core via MQTT using AWSIoTPythonSDK
body: <p>I have followed the AWS tutorial step by step. <a href="https://aws.amazon.com/premiumsupport/knowledge-center/iot-core-publish-mqtt-messages-python/" rel="nofollow noreferrer">https://aws.amazon.com/premiumsupport/knowledge-center/iot-core-publish-mqtt-messages-python/</a></p>
  <p>I have created the open-ended policy with the *, registered a thing and attached it to the policy, generated, downloaded, and activated the certificates. I have tried to connect and publish to a subscription using both the AWS IoT SDK for Python v2 and the original sdk but neither work. The code I'm using is straight from AWS's demo example connection code but they just wont connect.</p>
  <p>While using the AWS IoT SDK for Python v2 I get this error message:</p>
  <pre><code>RuntimeError: 1038 (AWS_IO_FILE_VALIDATION_FAILURE): A file was read and the input did not match the expected value
  </code></pre>
  <p>While using the original SDK I get this error message:</p>
  <pre><code>TimeoutError: [Errno 60] Operation timed out
  </code></pre>
  <p>The python code I'm using:</p>
  <pre><code># Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  # SPDX-License-Identifier: MIT-0
  
  import time as t
  import json
  import AWSIoTPythonSDK.MQTTLib as AWSIoTPyMQTT
  
  # Define ENDPOINT, CLIENT_ID, PATH_TO_CERT, PATH_TO_KEY, PATH_TO_ROOT, MESSAGE, TOPIC, and RANGE
  ENDPOINT = &quot;XXXXX-ats.iot.ap-southeast-2.amazonaws.com&quot;
  CLIENT_ID = &quot;testDevice&quot;
  PATH_TO_CERT = &quot;certs/XXXX-certificate.pem.crt&quot;
  PATH_TO_KEY = &quot;certs/XXXX-private.pem.key&quot;
  PATH_TO_ROOT = &quot;certs/root.pem&quot;
  MESSAGE = &quot;Hello World&quot;
  TOPIC = &quot;test/testing&quot;
  RANGE = 20
  
  myAWSIoTMQTTClient = AWSIoTPyMQTT.AWSIoTMQTTClient(CLIENT_ID)
  myAWSIoTMQTTClient.configureEndpoint(ENDPOINT, 8883)
  myAWSIoTMQTTClient.configureCredentials(PATH_TO_ROOT, PATH_TO_KEY, PATH_TO_CERT)
  
  myAWSIoTMQTTClient.connect()
  print('Begin Publish')
  for i in range (RANGE):
      data = &quot;{} [{}]&quot;.format(MESSAGE, i+1)
      message = {&quot;message&quot; : data}
      myAWSIoTMQTTClient.publish(TOPIC, json.dumps(message), 1) 
      print(&quot;Published: '&quot; + json.dumps(message) + &quot;' to the topic: &quot; + &quot;'test/testing'&quot;)
      t.sleep(0.1)
  print('Publish End')
  myAWSIoTMQTTClient.disconnect()
  </code></pre>
  <p>(I censored the endpoint and the certificate ID)</p>
  <p>(I'm using a macbook air and on a public school network)</p>