Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2f5101f1

Přidáno uživatelem Stanislav Král před téměř 4 roky(ů)

Re #8472 - Added a parameter to the craete_sscrt method in CryptographyService in order to be able to specify tha number of days for which the generated certificate will be valid.

Zobrazit rozdíly:

src/services/cryptography.py
92 92
            return self.__run_for_output(
93 93
                ["genrsa", PRIVATE_KEY_ENCRYPTION_METHOD, "-passout", f"pass:{passphrase}", "2048"]).decode()
94 94

  
95
    def create_sscrt(self, subject, key, config="", extensions="", key_pass=None):
95
    def create_sscrt(self, subject, key, config="", extensions="", key_pass=None, days=30):
96 96
        """
97 97
        Creates a root CA
98 98

  
......
101 101
        :param config: string containing the configuration to be used
102 102
        :param extensions: name of the section in the configuration representing extensions
103 103
        :param key_pass: passphrase of the private key
104
        :param days: number of days for which the certificate will be valid
104 105

  
105 106
        :return: string containing the generated certificate in PEM format
106 107
        """
......
110 111
        subj = self.__subject_to_param_format(subject)
111 112

  
112 113
        with TemporaryFile("openssl.conf", config) as conf_path:
113
            args = ["req", "-x509", "-new", "-subj", subj,
114
            args = ["req", "-x509", "-new", "-subj", subj, "-days", f"{days}",
114 115
                    "-key", "-"]
115 116
            if len(config) > 0:
116 117
                args.extend(["-config", conf_path])

Také k dispozici: Unified diff