nodemcu-firmware/tools/make_cert.py

43 lines
1.0 KiB
Python
Raw Normal View History

Adds support for verifying the certificate offered by an SSL server. Squashed commit of the following: commit 4439b8c45192f6dee1222df78bbb59f74509e0ee Author: philip <philip@gladstonefamily.net> Date: Sun Mar 6 20:23:21 2016 -0500 Fix the ignore commit a07ee5acdf91286607c3e2dce128c9b8bfd7bd80 Author: philip <philip@gladstonefamily.net> Date: Sun Mar 6 20:20:41 2016 -0500 Remove uneeded stuff commit b3604ace92fc13b30161d385c354b0f1c5fe4046 Author: philip <philip@gladstonefamily.net> Date: Sun Mar 6 20:15:26 2016 -0500 Remove client cert auth commit 6e48c633569630736a986cd07a59a12de954391e Author: philip <philip@gladstonefamily.net> Date: Sun Mar 6 20:11:42 2016 -0500 More cleanup commit d40eade405ef071d0d1b60d038566b5b8f2cafa3 Author: philip <philip@gladstonefamily.net> Date: Sat Mar 5 10:56:56 2016 -0500 Move to almost working version commit 1860a2d90afa94461c53bd41251d4870d6527f9d Author: philip <philip@gladstonefamily.net> Date: Fri Mar 4 08:04:09 2016 -0500 Changed the naem to server-ca.crt commit e7a315660843273fe62943b7fe8ee6c0541dada2 Author: philip <philip@gladstonefamily.net> Date: Thu Mar 3 21:16:26 2016 -0500 Update gitignores commit 2b037d185c396209b64381399c40821c15e1840e Author: philip <philip@gladstonefamily.net> Date: Thu Mar 3 08:56:17 2016 -0500 Getting better commit 763255cffba8e279158cd7f43391a3573efdeca8 Author: philip <philip@gladstonefamily.net> Date: Wed Mar 2 22:28:21 2016 -0500 Works a bit better commit a38325d1a47dbad255cb3e681da8415e8cf699ea Author: philip <philip@gladstonefamily.net> Date: Wed Mar 2 09:11:04 2016 -0500 First building version commit 4aef13da33470ed954f2eaf5f7ac0ac3dcdf3774 Merge: 180e147 ebb0c33 Author: philip <philip@gladstonefamily.net> Date: Tue Mar 1 22:03:06 2016 -0500 Merge remote-tracking branch 'upstream/dev' into ssl-client commit 180e147c1abdcf4046ad9be9b3c1a48f4a875312 Author: philip <philip@gladstonefamily.net> Date: Sun Feb 28 21:34:21 2016 -0500 Missing files from espressif Try to imporve layout Align the file names with the contents Missing file Review comments More review coments
2016-03-07 02:25:05 +01:00
import os
class Cert(object):
def __init__(self, name, buff):
self.name = name
self.len = len(buff)
self.buff = buff
pass
def __str__(self):
out_str = ['\0']*32
for i in range(len(self.name)):
out_str[i] = self.name[i]
out_str = "".join(out_str)
out_str += str(chr(self.len & 0xFF))
out_str += str(chr((self.len & 0xFF00) >> 8))
out_str += self.buff
return out_str
pass
def main():
cert_list = []
file_list = os.listdir(os.getcwd())
cert_file_list = []
for _file in file_list:
pos = _file.find(".cer")
if pos != -1:
cert_file_list.append(_file[:pos])
for cert_file in cert_file_list:
with open(cert_file+".cer", 'rb') as f:
buff = f.read()
cert_list.append(Cert(cert_file, buff))
with open('esp_ca_cert.bin', 'wb+') as f:
for _cert in cert_list:
f.write("%s" % _cert)
pass
if __name__ == '__main__':
main()