Follow these steps before trying to run any code.
- First, generate a Certificate Authority (CA).
openssl genrsa -out rootCA.key 2048
- Second, self-sign it.
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 365 -out rootCA.pem
- Next, install that CA on the system(s) you want to use it on. You'll have to find out how/where to install it for your system.
- After that, create a certificate for each device you want to use it for.
openssl genrsa -out device.key 2048
Then, generate a certificate signing request.
openssl req -new -key device.key -out device.csr
Pay careful attention the "Common Name" field. It must be the same as the common name for the CA, even if it's an IP address.
- Then, sign the CSR using the root-CA.
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 364 -sha256
- Finally, install the key and the certificate in your device(s).
Hi,
Thank you for sharing this information.
I am not clear about the common name field. I populated it with 127.0.0.1 in both the root certificate and the device certificate. Both certificates or in the same folder as the python codes for the server and the client. The keys are also in the same folder. I run this code in Windows but the common name I selected does not seem to work. Any information as to what I did wrong would be appreciated.
Thank you.