Thanks but this isn’t the problem. I’m using the aws https example direct from the digi-upython-master. It works on my 4g modem, and fails on my 3g modem. There is some difference in the SSL library. I have a feeling it has to do with hostname verification, but I cannot find the digi ssl.py source to confirm. When I test ssl without certs on a different site it works, so I know that ssl itself is not the problem.
Code I’m using from the sample that works on 4g but fails on 3g below. In my code I have populated the fill me in blanks.
AWS endpoint parameters.
TODO: replace with your account values.
HOST = b’FILL_ME_IN’ # ex: b’abcdefg1234567-ats’
REGION = b’FILL_ME_IN’ # ex: b’us-east-1’
THING_NAME = b’FILL_ME_IN’ # ex: b’IMEI_12345’
AWS_ENDPOINT = b’%s.iot.%s.amazonaws.com’ % (HOST, REGION)
SSL certificates.
SSL_PARAMS = {‘keyfile’: “/flash/cert/aws.key”,
‘certfile’: “/flash/cert/aws.crt”,
‘ca_certs’: “/flash/cert/aws.ca”}
def https_test(hostname=AWS_ENDPOINT, sslp=SSL_PARAMS):
“”"
Tests the HTTPS connectivity with AWS. Sends an HTTP request to obtain the
shadow of a thing and prints it.
:param hostname: AWS hostname to connect to.
:param sslp: SSL certificate parameters.
"""
# Connect to AWS.
s = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM,
usocket.IPPROTO_SEC)
w = ussl.wrap_socket(s, **sslp)
print("- Connecting to AWS... ", end="")
w.connect((hostname, 8443))
s.setblocking(False)
print("[OK]")
# Send HTTP request.
print("- Sending shadow request for thing '%s'... " % THING_NAME, end="")
w.write(b'GET /things/%s/shadow HTTP/1.0
’
b’Host: %s
’
b’
’ % (THING_NAME, hostname))
print(“[OK]”)
# Read answer.
print(“- Waiting for data… “, end=””)
while True:
data = w.read(1024)
if data:
print(“[OK]”)
print(“- Received shadow for thing ‘%s’:” % THING_NAME)
print(64 * “-”)
print(str(data, ‘utf-8’))
print(64 * “-”)
break
# Disconnect.
w.close()
print(“- Done”)
print(" ±----------------------------------+“)
print(” | XBee MicroPython AWS HTTPS Sample |“)
print(” ±----------------------------------+
")
conn = network.Cellular()
print(“- Waiting for the module to be connected to the cellular network… “,
end=””)
while not conn.isconnected():
time.sleep(5)
print(“[OK]”)