Lecture 8 - Python TLS - Context and SSLSocket_Handouts
Lecture 8 - Python TLS - Context and SSLSocket_Handouts
and SSLSocket
TLS Context
Creating the Context - Refresher
Purpose
• You would typically only need to set the
Context Purpose
• Purpose.SERVER_AUTH – for developing a
client
• Purpose.CLIENT_AUTH – for developing a
server
Default Settings
• Purpose.SERVER_AUTH
• Use central root certificate store
TLS Context
More Complex Settings
Private Certificates
• You can specify alternate trusted
certificates
• For self-signed or private authority
• Can be provided when creating the
context or later
TLS Versions
• What if the other side is using older
software
• May need to specify particular options in
context to enable older versions of TLS
Self-Signed Certificates
• Verification will typically fail
• You would have to specify the certificate to trust either:
• When creating Context
• Call load_cert_chain() after Context is created
Example - Browser
• Verification will fail
• Get failed certificate and temporarily store locally
• Ask user to trust certificate
• Call load_cert_chain() with stored certificate
• Try again – two attempts © 2024 Swinburne University of Technology 9
try:
…
Code that can fail
…
except Exception as e:
…
Handle exception
…
© 2024 Swinburne University of Technology 11
Project Introduction
• Introduction to Graded Project within your Portfolio
• Overview of requirements
• Overview of grading scheme
Week 8
Lab – Python Programming