Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 89aa967d

Přidáno uživatelem Michal Seják před téměř 4 roky(ů)

Re #8705 - Review updates.

Zobrazit rozdíly:

src/controllers/certificates_controller.py
132 132
                                return E_WRONG_PASSWORD, C_BAD_REQUEST
133 133
                            key = self.key_service.wrap_custom_key(key_pem, passphrase=None)
134 134
                        else:
135
                            key = self.key_service.create_new_key()                 # if "key" exists but is empty
135
                            return E_WRONG_PARAMETERS, C_BAD_REQUEST                # if "key" exists but is empty
136 136
                else:
137 137
                    return E_WRONG_PARAMETERS, C_BAD_REQUEST
138 138
            else:
139 139
                key = self.key_service.create_new_key()                             # if "key" does not exist
140
                                                                                    # TODO Honza: line 134 / 138, should
141
                                                                                    #   they both be allowed? I say one
142
                                                                                    #   of those branches should return
143
                                                                                    #   wrong params bad request (mby).
144 140

  
145 141
            if CA not in body or body[CA] is None:                                  # if issuer omitted (legal) or none
146 142
                cert = self.certificate_service.create_root_ca(                     # create a root CA
......
167 163
                f = self.certificate_service.create_ca if CA_ID in usages_dict and usages_dict[CA_ID] else \
168 164
                    self.certificate_service.create_end_cert
169 165

  
170
                try:
171
                    # noinspection PyTypeChecker
172
                    cert = f(                                                           # create inter CA or end cert
173
                        key,                                                            # according to whether 'CA' is among
174
                        subject,                                                        # the usages' fields
175
                        issuer,
176
                        issuer_key,
177
                        usages=usages_dict,
178
                        days=body[VALIDITY_DAYS]
179
                    )
180
                except CryptographyException as e:
181
                    return {"success": False, "data": e.message}, C_BAD_REQUEST
166
                # noinspection PyTypeChecker
167
                cert = f(                                                           # create inter CA or end cert
168
                    key,                                                            # according to whether 'CA' is among
169
                    subject,                                                        # the usages' fields
170
                    issuer,
171
                    issuer_key,
172
                    usages=usages_dict,
173
                    days=body[VALIDITY_DAYS]
174
                )
182 175

  
183 176
            if cert is not None:
184 177
                return {"success": True,

Také k dispozici: Unified diff