Skip to content

Commit

Permalink
Upate config a few scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
externl committed Jan 22, 2024
1 parent 48b90cb commit 39f64c4
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
run: pip install ruff

- name: Run Ruff
run: ruff check 'cpp' --ignore E402
run: ruff check . --exclude "scripts" --exclude "python" --ignore E402
49 changes: 36 additions & 13 deletions certs/makecerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
try:
import IceCertUtils
except Exception as ex:
print("couldn't load IceCertUtils, did you install the `zeroc-icecertutils'\n"
"package from the Python package repository?\nerror: " + str(ex))
print(
"couldn't load IceCertUtils, did you install the `zeroc-icecertutils'\n"
"package from the Python package repository?\nerror: " + str(ex)
)
sys.exit(1)


Expand All @@ -38,13 +40,15 @@ def usage():
usedns = False
impl = ""
try:
opts, args = getopt.getopt(sys.argv[1:], "hd", ["help", "debug", "ip=", "dns=", "use-dns", "impl="])
opts, args = getopt.getopt(
sys.argv[1:], "hd", ["help", "debug", "ip=", "dns=", "use-dns", "impl="]
)
except getopt.GetoptError as e:
print("Error %s " % e)
usage()
sys.exit(1)

for (o, a) in opts:
for o, a in opts:
if o == "-h" or o == "--help":
usage()
sys.exit(0)
Expand All @@ -65,7 +69,7 @@ def request(question, newvalue, value):
sys.stdout.write(question)
sys.stdout.flush()
input = sys.stdin.readline().strip()
if input == 'n':
if input == "n":
sys.stdout.write(newvalue)
sys.stdout.flush()
return sys.stdin.readline().strip()
Expand All @@ -81,15 +85,23 @@ def request(question, newvalue, value):
if not ip:
try:
ip = socket.gethostbyname(socket.gethostname())
except:
except Exception:
ip = "127.0.0.1"
ip = request("The IP address used for the server certificate will be: " + ip + "\n"
"Do you want to keep this IP address? (y/n) [y]", "IP : ", ip)
ip = request(
"The IP address used for the server certificate will be: " + ip + "\n"
"Do you want to keep this IP address? (y/n) [y]",
"IP : ",
ip,
)

if not dns:
dns = "localhost"
dns = request("The DNS name used for the server certificate will be: " + dns + "\n"
"Do you want to keep this DNS name? (y/n) [y]", "DNS : ", dns)
dns = request(
"The DNS name used for the server certificate will be: " + dns + "\n"
"Do you want to keep this DNS name? (y/n) [y]",
"DNS : ",
dns,
)

CertificateFactory = vars(IceCertUtils)[impl + "CertificateFactory"]
factory = CertificateFactory(debug=debug, cn="Ice Tests CA")
Expand All @@ -110,7 +122,13 @@ def request(question, newvalue, value):
#
# NOTE: server.pem is used by scripts/TestController.py
#
server = factory.create("server", cn=(dns if usedns else ip), ip=ip, dns=dns, extendedKeyUsage="serverAuth,clientAuth")
server = factory.create(
"server",
cn=(dns if usedns else ip),
ip=ip,
dns=dns,
extendedKeyUsage="serverAuth,clientAuth",
)
server.save("server.p12").save("server.pem")

try:
Expand All @@ -125,14 +143,19 @@ def request(question, newvalue, value):
for f in ["server.bks", "client.bks"]:
if os.path.exists(f):
os.remove(f)
print("warning: couldn't generate BKS certificates for Android applications:\n" + str(ex))
print(
"warning: couldn't generate BKS certificates for Android applications:\n"
+ str(ex)
)
print("Please fix this issue if you want to run the Android tests.")

except Exception as ex:
for f in ["server.jks", "client.jks"]:
if os.path.exists(f):
os.remove(f)
print("warning: couldn't generate JKS certificates for Java applications:\n" + str(ex))
print(
"warning: couldn't generate JKS certificates for Java applications:\n" + str(ex)
)
print("Please fix this issue if you want to run the Java tests.")

factory.destroy()
Loading

0 comments on commit 39f64c4

Please sign in to comment.