The before code shows a simple HTTP request without verifying the server or presenting a client certificate. The after code configures the client to present its certificate and verify the server's certificate using the CA, enabling mutual TLS authentication.
### Before: Service client without mutual TLS
import requests
response = requests.get('https://service-b.internal/api/data')
print(response.text)
### After: Service client with mutual TLS
import requests
# Paths to client cert and key, and CA cert
client_cert = ('/path/client.crt', '/path/client.key')
ca_cert = '/path/ca.crt'
response = requests.get('https://service-b.internal/api/data', cert=client_cert, verify=ca_cert)
print(response.text)