sanglems
Posts: 5
Joined: Mon Apr 10, 2017 6:58 am

Using Self-signed certificate.

Thu Jun 15, 2017 2:11 am

hi.
I have a system where the sensors' data get stored on memory stick and when the I access it over browser it reads that data and show it over. Now I have to make the system secured for which I am trying to use self-signed SSL certificate.
I got the certificate using:

Code: Select all

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
And my code looks like :

Code: Select all

import socket, ssl, os

context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
context.load_cert_chain(certfile="cert.pem", keyfile="key.pem")
Host=' '
PORT=443

bindsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
bindsocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
bindsocket.bind((HOST,PORT))
bindsocket.listen(5)

while True:
    newsocket, fromaddr = bindsocket.accept()
    connstream = context.wrap_socket(newsocket, server_side=True)
    data = connstream.recv(1024)
    print data
   //code to read from memory stick and sendall(response)
   newsocket.close()
whenever I try to access the server over browser it gives "This site can't provide a secure connection. IP******* sent a invalid response. ERR_SSL_PROTOCOL_ERROR".

I tried turning off firewall. Also tried to change the code bit here n there but cannot make it work.

I also tried to make the certificate trusted using:https://unix.stackexchange.com/question ... usted-list
But same error message.
I am very new to all the things getting used here. Any help will be really appreciated.
Thank you.

raspeyote
Posts: 2
Joined: Tue Dec 12, 2017 8:36 am

Re: Using Self-signed certificate.

Wed Jan 03, 2018 7:39 am

Is this for a web server? I got the same error in my browser because I hadn't configured Apache correctly.

Return to “Beginners”

Who is online

Users browsing this forum: pws and 48 guests