1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-09 22:36:14 +01:00

Fix the '9 - review the server certificate' option in cert trust prompt

This commit is contained in:
Daniel Mach 2022-10-11 10:11:18 +02:00
parent fbde8fc256
commit 3aae045aac

View File

@ -2,6 +2,8 @@ import binascii
import os
import socket
import ssl
import subprocess
import sys
import tempfile
import typing
@ -159,4 +161,11 @@ Would you like to
self.trust_permanently(cert)
return
elif r == "9":
print(cert.to_txt())
# TODO: avoid calling openssl to convert pem to text
pem = cert.public_bytes(encoding=serialization.Encoding.PEM).decode("utf-8")
cmd = ["openssl", "x509", "-text"]
try:
cert_text = subprocess.check_output(cmd, input=pem, encoding="utf-8")
print(cert_text)
except FileNotFoundError:
print("ERROR: Unable to display certificate because the 'openssl' executable is not available", file=sys.stderr)