This commit is contained in:
Your Name
2025-01-28 18:14:55 +01:00
parent 083d342373
commit d095e53cd6
10 changed files with 646 additions and 11 deletions

View File

@@ -100,7 +100,7 @@ ser_sara = serial.Serial(
try:
#step 1: import the certificate
print("****")
with open("/var/www/nebuleair_pro_4g/SARA/SSL/certificate/isrg-root-x2.der", "rb") as cert_file:
with open("/var/www/nebuleair_pro_4g/SARA/SSL/certificate/e6.der", "rb") as cert_file:
certificate = cert_file.read()
size_of_string = len(certificate)
@@ -108,7 +108,7 @@ try:
print("\033[0;33m Import certificate\033[0m")
# AT+USECMNG=0,<type>,<internal_name>,<data_size>
# type-> 0 -> trusted root CA
command = f'AT+USECMNG=0,0,"isrg-root-x2",{size_of_string}\r'
command = f'AT+USECMNG=0,0,"e6",{size_of_string}\r'
ser_sara.write((command + '\r').encode('utf-8'))
response_SARA_1 = read_complete_response(ser_sara)
print(response_SARA_1)
@@ -133,7 +133,7 @@ try:
# *******************************
# SECURITY PROFILE
# AT+USECPRF=<profile_id>[,<op_code>[,<param_val>]]
security_profile_id = 0
security_profile_id = 1
# op_code: 0 -> certificate validation level
@@ -147,9 +147,9 @@ try:
time.sleep(0.5)
# op_code: 1 -> minimum SSL/TLS version
# param_val : 0 -> any; server can use any version for the connection; 1-> LSv1.0;
# param_val : 0 -> any; server can use any version for the connection; 1-> LSv1.0; 2->TLSv1.1; 3->TLSv1.2;
print("\033[0;33mSet the security profile (params)\033[0m")
minimum_SSL_version = 0
minimum_SSL_version = 3
command = f'AT+USECPRF={security_profile_id},1,{minimum_SSL_version}\r'
ser_sara.write((command + '\r').encode('utf-8'))
response_SARA_5bb = read_complete_response(ser_sara, wait_for_line="OK")
@@ -157,8 +157,9 @@ try:
time.sleep(0.5)
#op_code: 2 -> cipher suite
# 0 (factory-programmed value): (0x0000) Automatic the cipher suite will be negotiated in the handshake process
print("\033[0;33mSet cipher \033[0m")
cipher_suite = 1
cipher_suite = 0
command = f'AT+USECPRF={security_profile_id},2,{cipher_suite}\r'
ser_sara.write((command + '\r').encode('utf-8'))
response_SARA_5cc = read_complete_response(ser_sara, wait_for_line="OK")
@@ -167,12 +168,21 @@ try:
# op_code: 3 -> trusted root certificate internal name
print("\033[0;33mSet the security profile (choose cert)\033[0m")
command = f'AT+USECPRF={security_profile_id},3,"isrg-root-x2"\r'
command = f'AT+USECPRF={security_profile_id},3,"e6"\r'
ser_sara.write((command + '\r').encode('utf-8'))
response_SARA_5c = read_complete_response(ser_sara, wait_for_line="OK")
print(response_SARA_5c)
time.sleep(0.5)
# op_code: 10 -> SNI (server name indication)
print("\033[0;33mSet the SNI\033[0m")
command = f'AT+USECPRF={security_profile_id},10,"{url}"\r'
ser_sara.write((command + '\r').encode('utf-8'))
response_SARA_5cf = read_complete_response(ser_sara, wait_for_line="OK")
print(response_SARA_5cf)
time.sleep(0.5)
# *************************
# *************************