Revize 87fd5afc
Přidáno uživatelem Stanislav Král před asi 4 roky(ů)
proj/services/cryptography.py | ||
---|---|---|
121 | 121 |
|
122 | 122 |
return self.__run_for_output(args, proc_input=bytes(key, encoding="utf-8")).decode() |
123 | 123 |
|
124 |
def __create_csr(self, subject, subject_key, subject_key_pass=""):
|
|
124 |
def __create_csr(self, subject, key, key_pass=""):
|
|
125 | 125 |
""" |
126 | 126 |
Creates a CSR (Certificate Signing Request) |
127 | 127 |
|
128 | 128 |
:param subject: an instance of <Subject> representing the subject to be added to the CSR |
129 |
:param subject_key: the private key of the subject to be used to generate the CSR
|
|
130 |
:param subject_key_pass: passphrase of the subject's private key
|
|
129 |
:param key: the private key of the subject to be used to generate the CSR |
|
130 |
:param key_pass: passphrase of the subject's private key |
|
131 | 131 |
:return: string containing the generated certificate signing request in PEM format |
132 | 132 |
""" |
133 | 133 |
|
... | ... | |
137 | 137 |
|
138 | 138 |
# add the passphrase even when None is passed. Otherwise when running tests with pytest some tests freeze |
139 | 139 |
# waiting for the passphrase to be typed in |
140 |
args.extend(["-passin", f"pass:{subject_key_pass}"])
|
|
140 |
args.extend(["-passin", f"pass:{key_pass}"]) |
|
141 | 141 |
|
142 |
return self.__run_for_output(args, proc_input=bytes(subject_key, encoding="utf-8")).decode()
|
|
142 |
return self.__run_for_output(args, proc_input=bytes(key, encoding="utf-8")).decode() |
|
143 | 143 |
|
144 | 144 |
def __sign_csr(self, csr, issuer_pem, issuer_key, issuer_key_pass=None, extensions="", days=30): |
145 | 145 |
""" |
... | ... | |
193 | 193 |
:param days: number of days for which the certificate will be valid |
194 | 194 |
:return: string containing the generated certificate in PEM format |
195 | 195 |
""" |
196 |
csr = self.__create_csr(subject, subject_key, subject_key_pass=subject_key_pass)
|
|
196 |
csr = self.__create_csr(subject, subject_key, key_pass=subject_key_pass) |
|
197 | 197 |
return self.__sign_csr(csr, issuer_pem, issuer_key, issuer_key_pass=issuer_key_pass, extensions=extensions, |
198 | 198 |
days=days) |
199 | 199 |
|
Také k dispozici: Unified diff
Re #8472 - Changed some parameter names in create_csr method and renamed make_csr_test.py to create_csr_test.py