Fix openssl certificate generation in behave tests (#2672)

--addext -> -addext (doesn't work on macOS)
set keyfile permissions to 600 (to avoid "private key file has group or world access")
This commit is contained in:
Polina Bungina
2023-05-12 10:42:53 +02:00
committed by GitHub
parent 7941c86775
commit ab9fea7d6b
+3 -1
View File
@@ -7,6 +7,7 @@ import psutil
import re
import shutil
import signal
import stat
import subprocess
import sys
import tempfile
@@ -1060,10 +1061,11 @@ def before_all(context):
try:
with open(os.devnull, 'w') as null:
ret = subprocess.call(['openssl', 'req', '-nodes', '-new', '-x509', '-subj', '/CN=batman.patroni',
'--addext', 'subjectAltName=IP:127.0.0.1', '-keyout', context.keyfile,
'-addext', 'subjectAltName=IP:127.0.0.1', '-keyout', context.keyfile,
'-out', context.certfile], stdout=null, stderr=null)
if ret != 0:
raise Exception
os.chmod(context.keyfile, stat.S_IWRITE | stat.S_IREAD)
except Exception:
context.keyfile = context.certfile = None