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

Merge pull request #1165 from dmach/display-ssl-cert

Fix the '9 - review the server certificate' option in cert trust prompt
This commit is contained in:
Daniel Mach 2022-10-12 09:15:55 +02:00 committed by GitHub
commit 298a1fba4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)