Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

ssl server python

1. openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem
2. Use the Code

import BaseHTTPServer, SimpleHTTPServer
import ssl

httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./server.pem', server_side=True) # Generate the CRT File by OPENSSL.
httpd.serve_forever()
Comment

python ssl

mport socket
import ssl

hostname = 'www.python.org'
context = ssl.create_default_context()

with socket.create_connection((hostname, 443)) as sock:
    with context.wrap_socket(sock, server_hostname=hostname) as ssock:
        print(ssock.version())
Comment

PREVIOUS NEXT
Code Example
Python :: Creating and writing to a new file 
Python :: up and down arrow matplotlib 
Python :: how to return a missing element in python 
Python :: labelencoder update 
Python :: change password django 
Python :: Rectangle with python 
Python :: python remove spaces from string 
Python :: shallow copy in python 
Python :: how to change the disabled color in tkinter 
Python :: why to use self in python 
Python :: cufflink install python jupyter 
Python :: python line break inside string 
Python :: créer fonction python 
Python :: how to make a random int in python 
Python :: python countdown from 20 down to 0 
Python :: decode multipart/form-data python lambda 
Python :: python print date, time and timezone 
Python :: time in python code 
Python :: pandas line plot dictionary 
Python :: creating class and object in python 
Python :: how to install django 
Python :: django jinja else if template tags 
Python :: cursor.fetchall() to list 
Python :: input function python 
Python :: smallest number of 3 python 
Python :: batch gradient descent python 
Python :: check if an object has an attribute in Python 
Python :: python singleton 
Python :: how to use modulo in python 
Python :: pandas divide multiple columns by one column 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =