Encode cert bytes to PEM encoded cert file.
(result)
| 367 | |
| 368 | |
| 369 | def encode_certificate(result): |
| 370 | """ |
| 371 | Encode cert bytes to PEM encoded cert file. |
| 372 | """ |
| 373 | cert_body = """-----BEGIN CERTIFICATE-----\n{0}\n-----END CERTIFICATE-----\n""".format( |
| 374 | "\n".join(textwrap.wrap(base64.b64encode(result).decode("utf8"), 64)) |
| 375 | ) |
| 376 | with open("{}/signed.crt".format(gettempdir()), "w") as signed_crt: |
| 377 | signed_crt.write(cert_body) |
| 378 | |
| 379 | return True |
| 380 | |
| 381 | |
| 382 | ## |