tls: Fix encoding handling in certificate-related functions (GH-8366)

80 column limit