"Update SSL certificate generation process"

This commit is contained in:
2025-05-26 10:48:36 +02:00
parent 0d7264524f
commit f063d07232
4 changed files with 74 additions and 54 deletions

View File

@@ -8,6 +8,8 @@ from cryptography.x509.oid import NameOID
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, NoEncryption
import ipaddress
import argparse
def generate_ssl_certificate():
"""
@@ -65,9 +67,8 @@ def generate_ssl_certificate():
san_list.append(x509.DNSName(hostname))
# IP-Adressen hinzufügen
import socket
for ip in ip_addresses:
san_list.append(x509.IPAddress(socket.inet_aton(ip)))
san_list.append(x509.IPAddress(ipaddress.IPv4Address(ip)))
# Zertifikat erstellen
cert = x509.CertificateBuilder().subject_name(
@@ -221,20 +222,27 @@ def copy_to_raspberry():
if __name__ == "__main__":
print("=== MYP SSL-Zertifikatsgenerator ===")
# Kommandozeilenargumente parsen
parser = argparse.ArgumentParser(description='MYP SSL-Zertifikatsgenerator')
parser.add_argument('--no-install', action='store_true', help='Zertifikat nicht im System installieren')
parser.add_argument('--no-raspberry', action='store_true', help='Zertifikat nicht auf den Raspberry Pi kopieren')
parser.add_argument('--quiet', action='store_true', help='Keine Benutzerinteraktion')
args = parser.parse_args()
# Zertifikat generieren
cert_generated = generate_ssl_certificate()
if not cert_generated:
print("Generierung des Zertifikats fehlgeschlagen.")
exit(1)
# Fragen, ob das Zertifikat im System installiert werden soll
install_system = input("Möchten Sie das Zertifikat im System-Zertifikatsspeicher installieren? (j/n): ").lower() == 'j'
if install_system:
install_certificate_system()
# System-Installation des Zertifikats
if not args.no_install:
if args.quiet or input("Möchten Sie das Zertifikat im System-Zertifikatsspeicher installieren? (j/n): ").lower() == 'j':
install_certificate_system()
# Fragen, ob das Zertifikat auf den Raspberry Pi kopiert werden soll
copy_raspberry = input("Möchten Sie das Zertifikat auf den Raspberry Pi kopieren? (j/n): ").lower() == 'j'
if copy_raspberry:
copy_to_raspberry()
# Kopieren auf Raspberry Pi
if not args.no_raspberry:
if args.quiet or input("Möchten Sie das Zertifikat auf den Raspberry Pi kopieren? (j/n): ").lower() == 'j':
copy_to_raspberry()
print("Vorgang abgeschlossen.")